added ex_rename() extention method to the driver added test suite for the ex_rename() extention method
changed ex_rename() to ex_rename_node() extention method Added the MockHttptestcase from ex_rename_node() extension method changed ex_rename() to ex_rename_node() extention method corrected the MockHttptestcase for ex_rename_node() method Added a fixture for ex_rename_node() method Signed-off-by: Tomaz Muraus <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/569f5eec Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/569f5eec Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/569f5eec Branch: refs/heads/trunk Commit: 569f5eec440c79734cd3139d19bb6a46c67275d1 Parents: 14640c3 Author: Rahul Ranjan <[email protected]> Authored: Wed Feb 19 03:11:38 2014 +0530 Committer: Tomaz Muraus <[email protected]> Committed: Wed Feb 19 19:20:24 2014 +0100 ---------------------------------------------------------------------- libcloud/compute/drivers/digitalocean.py | 6 ++++++ .../compute/fixtures/digitalocean/ex_rename_node.json | 1 + libcloud/test/compute/test_digitalocean.py | 11 +++++++++++ 3 files changed, 18 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/569f5eec/libcloud/compute/drivers/digitalocean.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py index 37434ab..962862c 100644 --- a/libcloud/compute/drivers/digitalocean.py +++ b/libcloud/compute/drivers/digitalocean.py @@ -127,6 +127,12 @@ class DigitalOceanNodeDriver(NodeDriver): params=params) return res.status == httplib.OK + def ex_rename_node(self, node, name): + params = {'name': name} + res = self.connection.request('/droplets/%s/rename/' % (node.id), + params=params) + return res.status == httplib.OK + def ex_list_ssh_keys(self): """ List all the available SSH keys. http://git-wip-us.apache.org/repos/asf/libcloud/blob/569f5eec/libcloud/test/compute/fixtures/digitalocean/ex_rename_node.json ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/fixtures/digitalocean/ex_rename_node.json b/libcloud/test/compute/fixtures/digitalocean/ex_rename_node.json new file mode 100644 index 0000000..bae818d --- /dev/null +++ b/libcloud/test/compute/fixtures/digitalocean/ex_rename_node.json @@ -0,0 +1 @@ +{"status":"OK","event_id":918910} http://git-wip-us.apache.org/repos/asf/libcloud/blob/569f5eec/libcloud/test/compute/test_digitalocean.py ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/test_digitalocean.py b/libcloud/test/compute/test_digitalocean.py index 86fe323..400b605 100644 --- a/libcloud/test/compute/test_digitalocean.py +++ b/libcloud/test/compute/test_digitalocean.py @@ -89,6 +89,11 @@ class DigitalOceanTests(unittest.TestCase): result = self.driver.destroy_node(node) self.assertTrue(result) + def test_ex_rename_node_success(self): + node = self.driver.list_nodes()[0] + result = self.driver.ex_rename_node(node, 'fedora helios') + self.assertTrue(result) + def test_ex_list_ssh_keys(self): keys = self.driver.ex_list_ssh_keys() self.assertEqual(len(keys), 1) @@ -133,6 +138,12 @@ class DigitalOceanMockHttp(MockHttpTestCase): body = self.fixtures.load('destroy_node.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + def _droplets_119461_rename(self, method, url, body, headers): + # reboot_node + self.assertUrlContainsQueryParams(url, {'name': 'fedora helios'}) + body = self.fixtures.load('ex_rename_node.json') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + def _ssh_keys(self, method, url, body, headers): body = self.fixtures.load('ex_list_ssh_keys.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK])
