You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by er...@apache.org on 2017/04/28 12:26:28 UTC
libcloud git commit: [google] Fix GCENodeDriver.ex_get_volume() if
zone param is GCEZone or NodeLocation
Repository: libcloud
Updated Branches:
refs/heads/trunk 03df6a8b5 -> 30c6f9cb6
[google] Fix GCENodeDriver.ex_get_volume() if zone param is GCEZone or NodeLocation
Closes #1047
Signed-off-by: Eric Johnson <er...@google.com>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/30c6f9cb
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/30c6f9cb
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/30c6f9cb
Branch: refs/heads/trunk
Commit: 30c6f9cb6eea590cfd23a5838e1d22280598fd06
Parents: 03df6a8
Author: Francisco Ros <fj...@doalitic.com>
Authored: Thu Apr 27 19:57:16 2017 +0200
Committer: Eric Johnson <er...@google.com>
Committed: Fri Apr 28 12:18:20 2017 +0000
----------------------------------------------------------------------
CHANGES.rst | 4 ++++
libcloud/compute/drivers/gce.py | 6 ++++++
libcloud/test/compute/test_gce.py | 20 ++++++++++++++++++++
3 files changed, 30 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/30c6f9cb/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 7979dc8..4f6f0d4 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -41,6 +41,10 @@ Common
Compute
~~~~~~~
+- [GOOGLE] Fix GCENodeDriver.ex_get_volume() when zone param is of class GCEZone or NodeLocation
+ [GITHUB-1047]
+ (Francisco Ros)
+
- [GOOGLE] Fix call to GCENodeDriver._ex_populate_volume_dict
[GITHUB-1046]
(Francisco Ros)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/30c6f9cb/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index 076e014..41eef06 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -7097,6 +7097,12 @@ class GCENodeDriver(NodeDriver):
# Make the API call and build volume dictionary
self._ex_populate_volume_dict()
+ try:
+ # if zone is of class GCEZone or NodeLocation, get name instead
+ zone = zone.name
+ except AttributeError:
+ pass
+
return self._ex_lookup_volume(name, zone)
def ex_get_region(self, name):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/30c6f9cb/libcloud/test/compute/test_gce.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py
index 922df96..f7c70be 100644
--- a/libcloud/test/compute/test_gce.py
+++ b/libcloud/test/compute/test_gce.py
@@ -89,6 +89,26 @@ class GCENodeDriverTest(GoogleTestCase, TestCaseMixin):
region2 = self.driver._get_region_from_zone(zone2)
self.assertEqual(region2.name, expected_region2)
+ def test_get_volume(self):
+ volume_name = 'lcdisk'
+ volume = self.driver.ex_get_volume(volume_name)
+ self.assertTrue(isinstance(volume, StorageVolume))
+ self.assertEqual(volume.name, volume_name)
+
+ def test_get_volume_location(self):
+ volume_name = 'lcdisk'
+ location = self.driver.zone
+ volume = self.driver.ex_get_volume(volume_name, zone=location)
+ self.assertTrue(isinstance(volume, StorageVolume))
+ self.assertEqual(volume.name, volume_name)
+
+ def test_get_volume_location_name(self):
+ volume_name = 'lcdisk'
+ location = self.driver.zone
+ volume = self.driver.ex_get_volume(volume_name, zone=location.name)
+ self.assertTrue(isinstance(volume, StorageVolume))
+ self.assertEqual(volume.name, volume_name)
+
def test_find_zone_or_region(self):
zone1 = self.driver._find_zone_or_region('libcloud-demo-np-node',
'instances')