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 2015/02/22 12:04:38 UTC
libcloud git commit: Implement `list_volume_snapshots(volume)` for
OpenStack.
Repository: libcloud
Updated Branches:
refs/heads/trunk 193c42f21 -> 0fafc7d38
Implement `list_volume_snapshots(volume)` for OpenStack.
Closes #450
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/0fafc7d3
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/0fafc7d3
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/0fafc7d3
Branch: refs/heads/trunk
Commit: 0fafc7d38c4894c65c5a7fa23eafa16119fa98b3
Parents: 193c42f
Author: Allard Hoeve <al...@byte.nl>
Authored: Thu Feb 12 14:06:48 2015 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sun Feb 22 12:00:34 2015 +0100
----------------------------------------------------------------------
CHANGES.rst | 6 +++++-
libcloud/compute/drivers/openstack.py | 4 ++++
.../fixtures/openstack_v1.1/_os_snapshots.json | 11 ++++++++++-
.../openstack_v1.1/_os_snapshots_rackspace.json | 11 ++++++++++-
libcloud/test/compute/test_openstack.py | 14 +++++++++++++-
5 files changed, 42 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/0fafc7d3/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index b8baa23..7ef3a75 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -25,7 +25,7 @@ Compute
(LIBCLOUD-664, GITHUB-451)
[Allard Hoeve]
-- Add ``volumes_attached`` attibute to ``node.extra`` in the OpenStack driver..
+- Add ``volumes_attached`` attibute to ``node.extra`` in the OpenStack driver.
(LIBCLOUD-668, GITHUB-462)
[Allard Hoeve]
@@ -34,6 +34,10 @@ Compute
(LIBCLOUD-649, GITHUB-430)
[Wojciech Wirkijowski]
+- Add ``list_volume_snapshots`` method to the OpenStack driver.
+ (LIBCLOUD-663, GITHUB-450)
+ [Allard Hoeve]
+
Changes with Apache Libcloud 0.17.0
-----------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/0fafc7d3/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index fce25af..da8c05b 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -1586,6 +1586,10 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
return self._to_snapshots(
self.connection.request('/os-snapshots').object)
+ def list_volume_snapshots(self, volume):
+ return [snapshot for snapshot in self.ex_list_snapshots()
+ if snapshot.extra['volume_id'] == volume.id]
+
def ex_create_snapshot(self, volume, name, description=None, force=False):
"""
Create a snapshot based off of a volume.
http://git-wip-us.apache.org/repos/asf/libcloud/blob/0fafc7d3/libcloud/test/compute/fixtures/openstack_v1.1/_os_snapshots.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/openstack_v1.1/_os_snapshots.json b/libcloud/test/compute/fixtures/openstack_v1.1/_os_snapshots.json
index 032b553..7094a76 100644
--- a/libcloud/test/compute/fixtures/openstack_v1.1/_os_snapshots.json
+++ b/libcloud/test/compute/fixtures/openstack_v1.1/_os_snapshots.json
@@ -17,6 +17,15 @@
"status": "available",
"size": 25,
"created_at": "2012-03-19T01:52:47Z"
+ },
+ {
+ "id": "4fbbdccf-e058-6502-8844-6feeffdf4cb5",
+ "display_name": "snap-003",
+ "display_description": "Another daily backup",
+ "volume_id": "cd76a3a1-c4ce-40f6-9b9f-07a61508938d",
+ "status": "available",
+ "size": 30,
+ "created_at": "2013-02-29T03:50:07Z"
}
]
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/0fafc7d3/libcloud/test/compute/fixtures/openstack_v1.1/_os_snapshots_rackspace.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/openstack_v1.1/_os_snapshots_rackspace.json b/libcloud/test/compute/fixtures/openstack_v1.1/_os_snapshots_rackspace.json
index 877945b..cad3a21 100644
--- a/libcloud/test/compute/fixtures/openstack_v1.1/_os_snapshots_rackspace.json
+++ b/libcloud/test/compute/fixtures/openstack_v1.1/_os_snapshots_rackspace.json
@@ -17,6 +17,15 @@
"status": "available",
"size": 25,
"createdAt": "2012-03-19T01:52:47Z"
+ },
+ {
+ "id": "4fbbdccf-e058-6502-8844-6feeffdf4cb5",
+ "displayName": "snap-003",
+ "displayDescription": "Another daily backup",
+ "volumeId": "cd76a3a1-c4ce-40f6-9b9f-07a61508938d",
+ "status": "available",
+ "size": 30,
+ "createdAt": "2013-02-29T03:50:07Z"
}
]
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/0fafc7d3/libcloud/test/compute/test_openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
index 7a20d04..e8b4cb0 100644
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -1395,9 +1395,21 @@ class OpenStack_1_1_Tests(unittest.TestCase, TestCaseMixin):
self.conn_classes[1].type = 'RACKSPACE'
snapshots = self.driver.ex_list_snapshots()
- self.assertEqual(len(snapshots), 2)
+ self.assertEqual(len(snapshots), 3)
self.assertEqual(snapshots[0].extra['name'], 'snap-001')
+ def test_list_volume_snapshots(self):
+ volume = self.driver.list_volumes()[0]
+
+ # rackspace needs a different mocked response for snapshots, but not for volumes
+ if self.driver_type.type == 'rackspace':
+ self.conn_classes[0].type = 'RACKSPACE'
+ self.conn_classes[1].type = 'RACKSPACE'
+
+ snapshots = self.driver.list_volume_snapshots(volume)
+ self.assertEqual(len(snapshots), 1)
+ self.assertEqual(snapshots[0].id, '4fbbdccf-e058-6502-8844-6feeffdf4cb5')
+
def test_ex_create_snapshot(self):
volume = self.driver.list_volumes()[0]
if self.driver_type.type == 'rackspace':