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 2013/12/26 17:55:52 UTC

[1/4] git commit: Issue LIBCLOUD-471: Add ex_get_console_output method to the EC2 driver.

Updated Branches:
  refs/heads/trunk 5a68e0070 -> 166a11f6e


Issue LIBCLOUD-471: Add ex_get_console_output method to the EC2 driver.

Signed-off-by: Tomaz Muraus <to...@apache.org>


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

Branch: refs/heads/trunk
Commit: f185e4490d76768bc61c7ffc314aa434490c9a7f
Parents: 5a68e00
Author: Chris DeRamus <ch...@divvycloud.com>
Authored: Thu Dec 26 08:34:05 2013 -0500
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Dec 26 17:13:01 2013 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/ec2.py                 | 31 ++++++++++++++++++++
 .../compute/fixtures/ec2/get_console_output.xml |  6 ++++
 libcloud/test/compute/test_ec2.py               |  9 ++++++
 3 files changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/f185e449/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index a13201e..4b389df 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -2689,6 +2689,37 @@ class BaseEC2NodeDriver(NodeDriver):
         res = self.connection.request(self.path, params=params).object
         return self._get_terminate_boolean(res)
 
+    def ex_get_console_output(self, node):
+        """
+        Get console output for the node. This returns a base64 decoded string
+
+        :param      node: Node which should be used
+        :type       node: :class:`Node`
+
+        :return:    Dictionary that contains the instance/node id, an
+                    ISO 8601 formatted datetime and base64 decoded
+                    console output for the node in question.
+        :rtype:     ``dict``
+        """
+        params = {
+            'Action': 'GetConsoleOutput',
+            'InstanceId': node.id
+        }
+
+        response = self.connection.request(self.path, params=params).object
+
+        timestamp = findattr(element=response,
+                             xpath='timestamp',
+                             namespace=NAMESPACE)
+
+        encoded_string = findattr(element=response,
+                                  xpath='output',
+                                  namespace=NAMESPACE)
+
+        return {'instance_id': node.id,
+                'timestamp': parse_date(timestamp),
+                'output': base64.b64decode(b(encoded_string))}
+
     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/f185e449/libcloud/test/compute/fixtures/ec2/get_console_output.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/ec2/get_console_output.xml b/libcloud/test/compute/fixtures/ec2/get_console_output.xml
new file mode 100644
index 0000000..5d74cd6
--- /dev/null
+++ b/libcloud/test/compute/fixtures/ec2/get_console_output.xml
@@ -0,0 +1,6 @@
+<GetConsoleOutputResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
+    <requestId>f0ffb5ce-8d62-4ab9-add7-67a0f99c9811</requestId>
+    <instanceId>i-40128925</instanceId>
+    <timestamp>2013-12-02T12:31:38.000Z</timestamp>
+    <output>VGVzdCBTdHJpbmc=</output>
+</GetConsoleOutputResponse>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/f185e449/libcloud/test/compute/test_ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index 239b9ef..3a29793 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -839,6 +839,11 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
         resp = self.driver.ex_delete_subnet(subnet=subnet)
         self.assertTrue(resp)
 
+    def test_ex_get_console_output(self):
+        node = self.driver.list_nodes()[0]
+        resp = self.driver.ex_get_console_output(node)
+        self.assertEqual('Test String', resp['output'])
+
 
 class EC2USWest1Tests(EC2Tests):
     region = 'us-west-1'
@@ -1146,6 +1151,10 @@ class EC2MockHttp(MockHttpTestCase):
         body = self.fixtures.load('delete_subnet.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _GetConsoleOutput(self, method, url, body, headers):
+        body = self.fixtures.load('get_console_output.xml')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
 
 class EucMockHttp(EC2MockHttp):
     fixtures = ComputeFileFixtures('ec2')


[3/4] git commit: Fix test failure under Python 3.

Posted by to...@apache.org.
Fix test failure under Python 3.


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

Branch: refs/heads/trunk
Commit: db86d13519405b72c771bb4c5d62e3017be98db2
Parents: e263208
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Dec 26 17:24:04 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Dec 26 17:52:35 2013 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/ec2.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/db86d135/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index 80b204f..bc9377f 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -2718,9 +2718,12 @@ class BaseEC2NodeDriver(NodeDriver):
                                   xpath='output',
                                   namespace=NAMESPACE)
 
+        timestamp = parse_date(timestamp)
+        output = base64.b64decode(b(encoded_string)).decode('utf-8')
+
         return {'instance_id': node.id,
-                'timestamp': parse_date(timestamp),
-                'output': base64.b64decode(b(encoded_string))}
+                'timestamp': timestamp,
+                'output': output}
 
     def _get_common_security_group_params(self, group_id, protocol,
                                           from_port, to_port, cidr_ips,


[4/4] git commit: Update CHANGES.

Posted by to...@apache.org.
Update CHANGES.


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

Branch: refs/heads/trunk
Commit: 166a11f6e40304ac61b81c1fff567d67040616a3
Parents: db86d13
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Dec 26 17:51:24 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Dec 26 17:52:35 2013 +0100

----------------------------------------------------------------------
 CHANGES | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/166a11f6/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 04190d1..290ea2f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -119,6 +119,10 @@ Changes with Apache Libcloud in development
      ex_create_subnet, ex_delete_subnet) to the EC2 driver. (LIBCLOUD-468)
      [Chris DeRamus]
 
+   - Add ex_get_console_output extension method to the EC2 driver.
+     (LIBCLOUD-471)
+     [Chris DeRamus]
+
   *) Storage
 
     - Allow user to specify 'Content-Disposition' header in the CloudFiles


[2/4] git commit: Update docstring - remove obsolete comment, clarify which keys the dictionary contains.

Posted by to...@apache.org.
Update docstring - remove obsolete comment, clarify which keys the dictionary
contains.


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

Branch: refs/heads/trunk
Commit: e263208c84638cfcfb5d06526143abd8b1412a08
Parents: f185e44
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Dec 26 17:20:56 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Dec 26 17:52:31 2013 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/ec2.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/e263208c/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index 4b389df..80b204f 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -2691,14 +2691,16 @@ class BaseEC2NodeDriver(NodeDriver):
 
     def ex_get_console_output(self, node):
         """
-        Get console output for the node. This returns a base64 decoded string
+        Get console output for the node.
 
         :param      node: Node which should be used
         :type       node: :class:`Node`
 
-        :return:    Dictionary that contains the instance/node id, an
-                    ISO 8601 formatted datetime and base64 decoded
-                    console output for the node in question.
+        :return:    Dictionary with the following keys:
+                    - instance_id (``str``)
+                    - timestamp (``datetime.datetime``) - timestamp of the last
+                      output
+                    - output (``str``) - console output
         :rtype:     ``dict``
         """
         params = {