Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions libcloud/compute/drivers/joyent.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@ def ex_start_node(self, node):
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 = []
Expand Down
12 changes: 11 additions & 1 deletion libcloud/test/compute/test_joyent.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ def test_ex_start_node(self):
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')
Expand All @@ -121,7 +130,8 @@ def _my_machines(self, method, url, body, headers):

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__':
Expand Down