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:19 UTC

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

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]