libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject libcloud git commit: Added JoyentNodeDriver.ex_get_node()
Date Fri, 26 Dec 2014 14:41:00 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 0486f77e7 -> 68a3461a6


Added JoyentNodeDriver.ex_get_node()

Joyent didn't have a method for get only one Node.

Because I doesn't want to make a for loop for find a node, I added this method.
Error raising is better too with that, a real Joyent's error message is now raised.

Closes #421

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


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

Branch: refs/heads/trunk
Commit: 68a3461a6279fb2e526a24f8590607b23045c144
Parents: 0486f77
Author: ZuluPro <montheanthony@hotmail.com>
Authored: Wed Dec 24 13:05:14 2014 +0100
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Fri Dec 26 12:16:06 2014 +0100

----------------------------------------------------------------------
 CHANGES.rst                          |  4 ++++
 libcloud/compute/drivers/joyent.py   | 13 +++++++++++++
 libcloud/test/compute/test_joyent.py | 12 +++++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/68a3461a/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 7ce653c..47a1ab6 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -103,6 +103,10 @@ Compute
   (GITHUB-417)
   [Viktor Petersson]
 
+- Add ``ex_get_node`` method to the Joyent driver.
+  (GITHUB-421)
+  [ZuluPro]
+
 Storage
 ~~~~~~~
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/68a3461a/libcloud/compute/drivers/joyent.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/joyent.py b/libcloud/compute/drivers/joyent.py
index 42bbae2..d1fa9c1 100644
--- a/libcloud/compute/drivers/joyent.py
+++ b/libcloud/compute/drivers/joyent.py
@@ -206,6 +206,19 @@ class JoyentNodeDriver(NodeDriver):
                                          data=data, method='POST')
         return result.status == httplib.ACCEPTED
 
+    def ex_get_node(self, node_id):
+        """
+        Return a Node object based on a node ID.
+
+        :param  node_id: ID of the node
+        :type   node_id: ``str``
+
+        :return:  A Node object for the node
+        :rtype:   :class:`Node`
+        """
+        result = self.connection.request('/my/machines/%s' % (node_id))
+        return self._to_node(result.object)
+
     def _to_node(self, data):
         state = NODE_STATE_MAP[data['state']]
         public_ips = []

http://git-wip-us.apache.org/repos/asf/libcloud/blob/68a3461a/libcloud/test/compute/test_joyent.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_joyent.py b/libcloud/test/compute/test_joyent.py
index 86b2890..90718fc 100644
--- a/libcloud/test/compute/test_joyent.py
+++ b/libcloud/test/compute/test_joyent.py
@@ -100,6 +100,15 @@ class JoyentTestCase(unittest.TestCase):
         node = self.driver.list_nodes()[0]
         self.assertTrue(self.driver.ex_start_node(node))
 
+    def test_ex_get_node(self):
+        node_id = '2fb67f5f-53f2-40ab-9d99-b9ff68cfb2ab'
+        node = self.driver.ex_get_node(node_id)
+        self.assertEqual(node.name, 'testlc')
+
+        missing_node = 'dummy-node'
+        self.assertRaises(Exception, self.driver.ex_get_node,
+                          missing_node, 'all')
+
 
 class JoyentHttp(MockHttp):
     fixtures = ComputeFileFixtures('joyent')
@@ -121,7 +130,8 @@ class JoyentHttp(MockHttp):
 
     def _my_machines_2fb67f5f_53f2_40ab_9d99_b9ff68cfb2ab(self, method, url,
                                                           body, headers):
-        return (httplib.ACCEPTED, '', {}, httplib.responses[httplib.ACCEPTED])
+        body = self.fixtures.load('my_machines_create.json')
+        return (httplib.ACCEPTED, body, {}, httplib.responses[httplib.ACCEPTED])
 
 
 if __name__ == '__main__':


Mime
View raw message