You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2014/09/27 19:15:27 UTC

git commit: Make openstack create_volume return a StorageVolume

Repository: libcloud
Updated Branches:
  refs/heads/trunk 4edca4b16 -> 00225d904


Make openstack create_volume return a StorageVolume

Closes #365

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


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

Branch: refs/heads/trunk
Commit: 00225d9044abd95c4cbdb0b473d8f97ff2c446bb
Parents: 4edca4b
Author: Gertjan Oude Lohuis <ge...@byte.nl>
Authored: Thu Sep 25 09:37:27 2014 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sat Sep 27 19:14:51 2014 +0200

----------------------------------------------------------------------
 CHANGES.rst                             | 7 +++++++
 libcloud/compute/drivers/openstack.py   | 5 +++--
 libcloud/test/compute/test_openstack.py | 4 +++-
 3 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/00225d90/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 15454fd..1873f1a 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -131,6 +131,13 @@ Compute
   (GITHUB-366)
   [Gertjan Oude Lohuis]
 
+- Fix ``create_volume`` method in the OpenStack driver to return a created
+  volume object (instance of StorageVolume) on success, instead of a boolean
+  indicating operation success.
+  (GITHUB-365)
+  [Gertjan Oude Lohuis]
+
+
 Storage
 ~~~~~~~
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/00225d90/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index e7a89f8..1d3b5ff 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -152,7 +152,7 @@ class OpenStackNodeDriver(NodeDriver, OpenStackDriverMixin):
         if snapshot:
             raise NotImplementedError(
                 "create_volume does not yet support create from snapshot")
-        return self.connection.request('/os-volumes',
+        resp = self.connection.request('/os-volumes',
                                        method='POST',
                                        data={
                                            'volume': {
@@ -165,7 +165,8 @@ class OpenStackNodeDriver(NodeDriver, OpenStackDriverMixin):
                                                },
                                                'availability_zone': location,
                                            }
-                                       }).success()
+                                       })
+        return self._to_volume(resp.object)
 
     def destroy_volume(self, volume):
         return self.connection.request('/os-volumes/%s' % volume.id,

http://git-wip-us.apache.org/repos/asf/libcloud/blob/00225d90/libcloud/test/compute/test_openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
index 1b0860d..930fff9 100644
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -923,7 +923,9 @@ class OpenStack_1_1_Tests(unittest.TestCase, TestCaseMixin):
         self.assertTrue(self.node.reboot())
 
     def test_create_volume(self):
-        self.assertEqual(self.driver.create_volume(1, 'test'), True)
+        volume = self.driver.create_volume(1, 'test')
+        self.assertEqual(volume.name, 'test')
+        self.assertEqual(volume.size, 1)
 
     def test_destroy_volume(self):
         volume = self.driver.ex_get_volume(