You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2022/01/28 21:46:18 UTC

[libcloud] branch trunk updated (90971e1 -> d918c5a)

This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git.


    from 90971e1  Merge pull request #1637 from micafer/fix_1595
     new 8be3308  fix #1641: [EC2] Add missing "creation_date" NodeImage extra
     new d918c5a  Add test which verifies the code doesn't throw if creationDate attribute is not present.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGES.rst                                        |  4 +++
 libcloud/compute/drivers/ec2.py                    |  1 +
 .../test/compute/fixtures/ec2/describe_images.xml  | 33 ++++++++++++++++++++++
 libcloud/test/compute/test_ec2.py                  | 12 ++++++--
 4 files changed, 48 insertions(+), 2 deletions(-)

[libcloud] 01/02: fix #1641: [EC2] Add missing "creation_date" NodeImage extra

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit 8be3308b82d0295159c31936168405e609d464a6
Author: mazerty <ma...@gmail.com>
AuthorDate: Mon Jan 10 18:18:12 2022 +0100

    fix #1641: [EC2] Add missing "creation_date" NodeImage extra
---
 CHANGES.rst                                            | 4 ++++
 libcloud/compute/drivers/ec2.py                        | 1 +
 libcloud/test/compute/fixtures/ec2/describe_images.xml | 2 ++
 libcloud/test/compute/test_ec2.py                      | 3 +++
 4 files changed, 10 insertions(+)

diff --git a/CHANGES.rst b/CHANGES.rst
index 02e85db..d50b0a9 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -29,6 +29,10 @@ Compute
   (GITHUB-1595)
   [Miguel Caballer - @micafer]
 
+- [EC2] Add missing ``creation_date`` NodeImage extra.
+  (GITHUB-1641)
+  [Thomas JOUANNOT - @mazerty]
+
 Storage
 ~~~~~~~
 
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index aec2be3..a96126c 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -674,6 +674,7 @@ RESOURCE_EXTRA_ATTRIBUTES_MAP = {
         "ramdisk_id": {"xpath": "ramdiskId", "transform_func": str},
         "ena_support": {"xpath": "enaSupport", "transform_func": str},
         "sriov_net_support": {"xpath": "sriovNetSupport", "transform_func": str},
+        "creation_date": {"xpath": "creationDate", "transform_func": parse_date},
     },
     "network": {
         "state": {"xpath": "state", "transform_func": str},
diff --git a/libcloud/test/compute/fixtures/ec2/describe_images.xml b/libcloud/test/compute/fixtures/ec2/describe_images.xml
index 167015a..07e9fa3 100644
--- a/libcloud/test/compute/fixtures/ec2/describe_images.xml
+++ b/libcloud/test/compute/fixtures/ec2/describe_images.xml
@@ -36,6 +36,7 @@
             </blockDeviceMapping>
             <virtualizationType>paravirtual</virtualizationType>
             <hypervisor>xen</hypervisor>
+            <creationDate>2021-01-10T18:24:00.000Z</creationDate>
         </item>
         <item>
             <imageId>ami-85b2a8ae</imageId>
@@ -67,6 +68,7 @@
             </blockDeviceMapping>
             <virtualizationType>paravirtual</virtualizationType>
             <hypervisor>xen</hypervisor>
+            <creationDate>2021-01-10T18:25:00.000Z</creationDate>
         </item>
     </imagesSet>
 </DescribeImagesResponse>
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index 88c56ed..6dd47d4 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -585,6 +585,7 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
         self.assertEqual(ephemeral, "ephemeral0")
         billing_product1 = images[0].extra["billing_products"][0]
         self.assertEqual(billing_product1, "ab-5dh78019")
+        self.assertIsInstance(images[0].extra["creation_date"], datetime)
 
         location = "123456788908/Test Image 2"
         self.assertEqual(images[1].id, "ami-85b2a8ae")
@@ -595,6 +596,7 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
         billing_product2 = images[1].extra["billing_products"][0]
         self.assertEqual(billing_product2, "as-6dr90319")
         self.assertEqual(size, 20)
+        self.assertIsInstance(images[1].extra["creation_date"], datetime)
 
     def test_list_images_with_image_ids(self):
         EC2MockHttp.type = "ex_imageids"
@@ -615,6 +617,7 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
         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")
+        self.assertIsInstance(image.extra["creation_date"], datetime)
 
     def test_copy_image(self):
         image = self.driver.list_images()[0]

[libcloud] 02/02: Add test which verifies the code doesn't throw if creationDate attribute is not present.

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit d918c5ab2e58dd882ab66f2123f6621129fb918b
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Fri Jan 28 22:30:55 2022 +0100

    Add test which verifies the code doesn't throw if creationDate attribute
    is not present.
---
 .../test/compute/fixtures/ec2/describe_images.xml  | 31 ++++++++++++++++++++++
 libcloud/test/compute/test_ec2.py                  |  9 +++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/libcloud/test/compute/fixtures/ec2/describe_images.xml b/libcloud/test/compute/fixtures/ec2/describe_images.xml
index 07e9fa3..650fb91 100644
--- a/libcloud/test/compute/fixtures/ec2/describe_images.xml
+++ b/libcloud/test/compute/fixtures/ec2/describe_images.xml
@@ -70,5 +70,36 @@
             <hypervisor>xen</hypervisor>
             <creationDate>2021-01-10T18:25:00.000Z</creationDate>
         </item>
+        <item>
+            <imageId>ami-85b2a8ac</imageId>
+            <imageLocation>123456788908/Test Image 3</imageLocation>
+            <imageState>available</imageState>
+            <imageOwnerId>123456788908</imageOwnerId>
+            <isPublic>false</isPublic>
+            <architecture>x86_64</architecture>
+            <imageType>machine</imageType>
+            <kernelId>aki-88aa75e1</kernelId>
+            <name>Test Image 3</name>
+            <rootDeviceType>ebs</rootDeviceType>
+            <rootDeviceName>/dev/sda1</rootDeviceName>
+            <billingProducts>
+                <item>
+                    <billingProduct>as-6dr90319</billingProduct>
+                </item>
+            </billingProducts>
+            <blockDeviceMapping>
+                <item>
+                    <deviceName>/dev/sda1</deviceName>
+                    <ebs>
+                        <snapshotId>snap-c0bfbbdb</snapshotId>
+                        <volumeSize>20</volumeSize>
+                        <deleteOnTermination>false</deleteOnTermination>
+                        <volumeType>standard</volumeType>
+                    </ebs>
+                </item>
+            </blockDeviceMapping>
+            <virtualizationType>paravirtual</virtualizationType>
+            <hypervisor>xen</hypervisor>
+        </item>
     </imagesSet>
 </DescribeImagesResponse>
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index 6dd47d4..8b8569b 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -574,7 +574,7 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
     def test_list_images(self):
         images = self.driver.list_images()
 
-        self.assertEqual(len(images), 2)
+        self.assertEqual(len(images), 3)
         location = "123456788908/Test Image"
         self.assertEqual(images[0].id, "ami-57ba933a")
         self.assertEqual(images[0].name, "Test Image")
@@ -598,6 +598,11 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
         self.assertEqual(size, 20)
         self.assertIsInstance(images[1].extra["creation_date"], datetime)
 
+        self.assertEqual(images[2].id, "ami-85b2a8ac")
+        self.assertEqual(images[2].name, "Test Image 3")
+        self.assertEqual(size, 20)
+        self.assertIsNone(images[2].extra["creation_date"])
+
     def test_list_images_with_image_ids(self):
         EC2MockHttp.type = "ex_imageids"
         images = self.driver.list_images(ex_image_ids=["ami-57ba933a"])
@@ -608,7 +613,7 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
     def test_list_images_with_executable_by(self):
         images = self.driver.list_images(ex_executableby="self")
 
-        self.assertEqual(len(images), 2)
+        self.assertEqual(len(images), 3)
 
     def test_get_image(self):
         image = self.driver.get_image("ami-57ba933a")