Added Gandi ex_get_volume with test Closes #534
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/cec4b497 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/cec4b497 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/cec4b497 Branch: refs/heads/trunk Commit: cec4b497e0875251f76787a04729b7256d806a2d Parents: 915bc1a Author: ZuluPro <[email protected]> Authored: Tue Jun 2 13:45:20 2015 -0400 Committer: Tomaz Muraus <[email protected]> Committed: Sat Jun 13 20:32:16 2015 +0800 ---------------------------------------------------------------------- libcloud/compute/drivers/gandi.py | 13 +++++++++++++ libcloud/test/compute/test_gandi.py | 4 ++++ 2 files changed, 17 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/cec4b497/libcloud/compute/drivers/gandi.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/gandi.py b/libcloud/compute/drivers/gandi.py index ba6e89b..844850a 100644 --- a/libcloud/compute/drivers/gandi.py +++ b/libcloud/compute/drivers/gandi.py @@ -461,6 +461,19 @@ class GandiNodeDriver(BaseGandiDriver, NodeDriver): res = self.connection.request('hosting.disk.list', {}) return self._to_volumes(res.object) + def ex_get_volume(self, volume_id): + """ + Return a Volume object based on a volume ID. + + :param volume_id: The ID of the volume + :type volume_id: ``int`` + + :return: A StorageVolume object for the volume + :rtype: :class:`StorageVolume` + """ + res = self.connection.request('hosting.disk.info', volume_id) + return self._to_volume(res.object) + def create_volume(self, size, name, location=None, snapshot=None): """ Create a volume (disk). http://git-wip-us.apache.org/repos/asf/libcloud/blob/cec4b497/libcloud/test/compute/test_gandi.py ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/test_gandi.py b/libcloud/test/compute/test_gandi.py index ae01e6d..1cdbcf2 100644 --- a/libcloud/test/compute/test_gandi.py +++ b/libcloud/test/compute/test_gandi.py @@ -175,6 +175,10 @@ class GandiTests(unittest.TestCase): node = self.driver.ex_get_node(34951) self.assertEqual(node.name, "test2") + def test_ex_get_volume(self): + volume = self.driver.ex_get_volume(1263) + self.assertEqual(volume.name, "libcloud") + class GandiRatingTests(unittest.TestCase):
