libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [1/2] libcloud git commit: ex_creation_time method for ec2 and digitalocean Closes #697 ec2 keeps the created time string in 'launch_time' and digital ocean keeps it in 'created_at'
Date Wed, 10 Feb 2016 01:00:39 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 022d01edd -> e14dbf2ce


ex_creation_time method for ec2 and digitalocean
Closes #697
ec2 keeps the created time string in 'launch_time' and digital ocean
keeps it in 'created_at'


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

Branch: refs/heads/trunk
Commit: e513687ea8e335b4a71d9f6e569f61bfcb65b0e9
Parents: 17c2217
Author: Rick van de Loo <rickvandeloo@gmail.com>
Authored: Tue Feb 9 22:40:24 2016 +0100
Committer: anthony-shaw <anthony.p.shaw@gmail.com>
Committed: Wed Feb 10 11:59:48 2016 +1100

----------------------------------------------------------------------
 libcloud/compute/drivers/digitalocean.py      | 12 ++++++++++++
 libcloud/compute/drivers/ec2.py               | 12 ++++++++++++
 libcloud/test/compute/test_digitalocean_v2.py |  5 +++++
 libcloud/test/compute/test_ec2.py             | 13 +++++++++++++
 4 files changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/e513687e/libcloud/compute/drivers/digitalocean.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py
index a5c3bb9..d0b3d7b 100644
--- a/libcloud/compute/drivers/digitalocean.py
+++ b/libcloud/compute/drivers/digitalocean.py
@@ -453,6 +453,18 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
                                       method='DELETE')
         return res.status == httplib.NO_CONTENT
 
+    def ex_get_creation_time(self, node):
+        """
+        Return the date and time that represent when the Instance was created.
+        :param      node: Node instance
+        :type       node: :class:`Node`
+
+        :return: ISO8601 combined date and time format string for when the
+         Droplet was created.
+        :rtype: ``str``
+        """
+        return node.extra['created_at']
+
     def get_image(self, image_id):
         """
         Get an image based on an image_id

http://git-wip-us.apache.org/repos/asf/libcloud/blob/e513687e/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index b57a1eb..1df3efd 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -4256,6 +4256,18 @@ class BaseEC2NodeDriver(NodeDriver):
         """
         return node.extra['tags']
 
+    def ex_get_creation_time(self, node):
+        """
+        Return the date and time that represent when the Instance was created.
+        :param      node: Node instance
+        :type       node: :class:`Node
+
+        :return: ISO8601 combined date and time format string for when the
+                 Instance was created.
+        :rtype: ``str``
+        """
+        return node.extra['launch_time']
+
     def ex_allocate_address(self, domain='standard'):
         """
         Allocate a new Elastic IP address for EC2 classic or VPC

http://git-wip-us.apache.org/repos/asf/libcloud/blob/e513687e/libcloud/test/compute/test_digitalocean_v2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_digitalocean_v2.py b/libcloud/test/compute/test_digitalocean_v2.py
index e666ce5..a4a1b01 100644
--- a/libcloud/test/compute/test_digitalocean_v2.py
+++ b/libcloud/test/compute/test_digitalocean_v2.py
@@ -142,6 +142,11 @@ class DigitalOcean_v2_Tests(LibcloudTestCase):
         result = self.driver.destroy_node(node)
         self.assertTrue(result)
 
+    def test_ex_get_creation_time(self):
+        node = self.driver.list_nodes()[0]
+        creation_time = self.driver.ex_get_creation_time(node)
+        self.assertEqual(creation_time, "2014-11-14T16:29:21Z")
+
     def test_ex_rename_node_success(self):
         node = self.driver.list_nodes()[0]
         DigitalOceanMockHttp.type = 'RENAME'

http://git-wip-us.apache.org/repos/asf/libcloud/blob/e513687e/libcloud/test/compute/test_ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index b800066..243425c 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -971,6 +971,19 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
         self.assertEqual(metadata['Num'], '42')
         self.assertEqual(len(metadata), 3)
 
+    def test_ex_get_creation_time(self):
+        image = NodeImage(id='ami-be3adfd8',
+                          name=self.image_name,
+                          driver=self.driver)
+        size = NodeSize('m1.small', 'Small Instance', None, None, None, None,
+                        driver=self.driver)
+        node = self.driver.create_node(name='foo',
+                                       image=image,
+                                       size=size)
+
+        creation_time = self.driver.ex_get_creation_time(node)
+        self.assertEqual(creation_time, '2007-08-07T11:51:50.000Z')
+
     def test_ex_get_limits(self):
         limits = self.driver.ex_get_limits()
 


Mime
View raw message