libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [1/9] git commit: LIBCLOUD-511: Added support for obtaining console output for OpenStack nodes. New tests are also included.
Date Wed, 05 Feb 2014 19:44:57 GMT
Updated Branches:
  refs/heads/trunk 71aff983c -> 8e36cb5ec


LIBCLOUD-511: Added support for obtaining console output for OpenStack nodes. New tests are
also included.


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

Branch: refs/heads/trunk
Commit: 5e9601f55ffecaad6969372bb04569642ad9863f
Parents: 71aff98
Author: Chris DeRamus <chris@divvycloud.com>
Authored: Tue Feb 4 08:20:46 2014 -0500
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Tue Feb 4 15:16:45 2014 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/openstack.py           | 25 ++++++++++++++++++++
 .../_servers_12086_console_output.json          |  3 +++
 libcloud/test/compute/test_openstack.py         | 16 +++++++++++++
 3 files changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/5e9601f5/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index 137dc30..db5c7f1 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -1572,6 +1572,31 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
                                        method='DELETE')
         return resp.status == httplib.ACCEPTED
 
+    def ex_get_console_output(self, node, length=None):
+        """
+        Get console output
+
+        :param      node: node
+        :type       node: :class:`Node`
+
+        :param      length: Optional number of lines to fetch from the
+                            console log
+        :type       length: ``int``
+
+        :return: Dictionary with the output
+        :rtype: ``dict``
+        """
+
+        data = {
+            "os-getConsoleOutput": {
+                "length": length
+            }
+        }
+
+        resp = self.connection.request('/servers/%s/action' % node.id,
+                                       method='POST', data=data).object
+        return resp
+
     def _to_security_group_rules(self, obj):
         return [self._to_security_group_rule(security_group_rule) for
                 security_group_rule in obj]

http://git-wip-us.apache.org/repos/asf/libcloud/blob/5e9601f5/libcloud/test/compute/fixtures/openstack_v1.1/_servers_12086_console_output.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/openstack_v1.1/_servers_12086_console_output.json
b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_12086_console_output.json
new file mode 100644
index 0000000..27ffe7d
--- /dev/null
+++ b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_12086_console_output.json
@@ -0,0 +1,3 @@
+{
+    "output": "FAKE CONSOLE OUTPUT\nANOTHER\nLAST LINE"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/5e9601f5/libcloud/test/compute/test_openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
index 0df6dd3..a249dfc 100644
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -1524,6 +1524,15 @@ class OpenStack_1_1_Tests(unittest.TestCase, TestCaseMixin):
         ret = self.driver.ex_resume_node(node)
         self.assertTrue(ret is True)
 
+    def test_ex_get_console_output(self):
+        node = Node(
+            id='12086', name=None, state=None,
+            public_ips=None, private_ips=None, driver=self.driver,
+        )
+        resp = self.driver.ex_get_console_output(node)
+        expected_output = 'FAKE CONSOLE OUTPUT\nANOTHER\nLAST LINE'
+        self.assertEqual(resp['output'], expected_output)
+
 
 class OpenStack_1_1_FactoryMethodTests(OpenStack_1_1_Tests):
     should_list_locations = False
@@ -1862,6 +1871,13 @@ class OpenStack_1_1_MockHttp(MockHttpTestCase):
 
         return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])
 
+    def _v1_1_slug_servers_12086_action(self, method, url, body, headers):
+        if method == "POST":
+            body = self.fixtures.load('_servers_12086_console_output.json')
+            return (httplib.ACCEPTED, body, self.json_content_headers, httplib.responses[httplib.OK])
+        else:
+            raise NotImplementedError()
+
 # This exists because the nova compute url in devstack has v2 in there but the v1.1 fixtures
 # work fine.
 


Mime
View raw message