You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2016/09/30 05:37:20 UTC
[1/2] libcloud git commit: StorageVolumeSnapshot now has a .name
Repository: libcloud
Updated Branches:
refs/heads/trunk 0ae5c1062 -> b93d00538
StorageVolumeSnapshot now has a .name
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/6395d62b
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/6395d62b
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/6395d62b
Branch: refs/heads/trunk
Commit: 6395d62b660980e1c3efc1f32312c6a8fee194e2
Parents: 0ae5c10
Author: Allard Hoeve <al...@gmail.com>
Authored: Fri Sep 23 16:30:57 2016 +0200
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri Sep 30 15:36:54 2016 +1000
----------------------------------------------------------------------
CHANGES.rst | 6 ++++++
libcloud/compute/base.py | 10 +++++++---
libcloud/compute/drivers/ec2.py | 3 ++-
libcloud/compute/drivers/gce.py | 3 +--
libcloud/compute/drivers/openstack.py | 3 ++-
libcloud/compute/drivers/rackspace.py | 3 ++-
libcloud/test/compute/test_ec2.py | 1 +
libcloud/test/compute/test_gce.py | 1 +
libcloud/test/compute/test_openstack.py | 1 +
9 files changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6395d62b/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 2d60534..34b8082 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -28,6 +28,12 @@ Compute
optional when working with newer OpenStack versions. The OpenStack driver will now
only post thost arguments if they are non-`NoneType`.
(GITHUB-866)
+
+- StorageVolumeSnapshot now has an attribute `name` that has the name of the snapshot
+ if the provider supports it. This used to be `.extra['name']`, but that is inconsistent
+ with `Node` and `StorageVolume`. The `extra` dict still holds `name` for backwards
+ compatibility.
+ (GITHUB-867)
[Allard Hoeve]
Container
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6395d62b/libcloud/compute/base.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index f4d4961..891a042 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -559,7 +559,7 @@ class VolumeSnapshot(object):
A base VolumeSnapshot class to derive from.
"""
def __init__(self, id, driver, size=None, extra=None, created=None,
- state=None):
+ state=None, name=None):
"""
VolumeSnapshot constructor.
@@ -583,6 +583,9 @@ class VolumeSnapshot(object):
:param state: A string representing the state the snapshot is
in. See `libcloud.compute.types.StorageVolumeState`.
:type state: ``str``
+
+ :param name: A string representing the name of the snapshot
+ :type name: ``str``
"""
self.id = id
self.driver = driver
@@ -590,6 +593,7 @@ class VolumeSnapshot(object):
self.extra = extra or {}
self.created = created
self.state = state
+ self.name = name
def destroy(self):
"""
@@ -600,8 +604,8 @@ class VolumeSnapshot(object):
return self.driver.destroy_volume_snapshot(snapshot=self)
def __repr__(self):
- return ('<VolumeSnapshot id=%s size=%s driver=%s state=%s>' %
- (self.id, self.size, self.driver.name, self.state))
+ return ('<VolumeSnapshot "%s" id=%s size=%s driver=%s state=%s>' %
+ (self.name, self.id, self.size, self.driver.name, self.state))
class KeyPair(object):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6395d62b/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index bc382e4..083fa4a 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -5601,7 +5601,8 @@ class BaseEC2NodeDriver(NodeDriver):
driver=self,
extra=extra,
created=created,
- state=state)
+ state=state,
+ name=name)
def _to_key_pairs(self, elems):
key_pairs = [self._to_key_pair(elem=elem) for elem in elems]
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6395d62b/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index f815ab0..e9e5471 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -709,9 +709,8 @@ class GCERegion(UuidMixin):
class GCESnapshot(VolumeSnapshot):
def __init__(self, id, name, size, status, driver, extra=None,
created=None):
- self.name = name
self.status = status
- super(GCESnapshot, self).__init__(id, driver, size, extra, created)
+ super(GCESnapshot, self).__init__(id, driver, size, extra, created, name=name)
class GCETargetHttpProxy(UuidMixin):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6395d62b/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index 0a34866..8afd8fb 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -2198,7 +2198,8 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
snapshot = VolumeSnapshot(id=data['id'], driver=self,
size=data['size'], extra=extra,
- created=created_dt, state=state)
+ created=created_dt, state=state,
+ name=display_name)
return snapshot
def _to_size(self, api_flavor, price=None, bandwidth=None):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6395d62b/libcloud/compute/drivers/rackspace.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/rackspace.py b/libcloud/compute/drivers/rackspace.py
index 4aab926..fc28184 100644
--- a/libcloud/compute/drivers/rackspace.py
+++ b/libcloud/compute/drivers/rackspace.py
@@ -242,7 +242,8 @@ class RackspaceNodeDriver(OpenStack_1_1_NodeDriver):
size=api_node['size'],
extra=extra,
created=created_td,
- state=state)
+ state=state,
+ name=api_node['displayName'])
return snapshot
def _ex_connection_class_kwargs(self):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6395d62b/libcloud/test/compute/test_ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index 307b2e3..2b24776 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -903,6 +903,7 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
self.assertEqual('Daily Backup', snaps[0].extra['description'])
self.assertEqual('snap-18349159', snaps[1].id)
+ self.assertEqual('DB Backup 1', snaps[1].name)
self.assertEqual(VolumeSnapshotState.AVAILABLE, snaps[1].state)
self.assertEqual('vol-b5a2c1v9', snaps[1].extra['volume_id'])
self.assertEqual(15, snaps[1].size)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6395d62b/libcloud/test/compute/test_gce.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py
index ebfed8c..75a53f1 100644
--- a/libcloud/test/compute/test_gce.py
+++ b/libcloud/test/compute/test_gce.py
@@ -1053,6 +1053,7 @@ class GCENodeDriverTest(GoogleTestCase, TestCaseMixin):
snapshot_name = 'lcsnapshot'
volume = self.driver.ex_get_volume('lcdisk')
snapshot = volume.snapshot(snapshot_name)
+
self.assertEqual(snapshot.name, snapshot_name)
self.assertEqual(snapshot.size, '10')
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6395d62b/libcloud/test/compute/test_openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
index 71a2fab..fad57e3 100644
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -1480,6 +1480,7 @@ class OpenStack_1_1_Tests(unittest.TestCase, TestCaseMixin):
self.assertEqual(snapshots[0].created, datetime.datetime(2012, 2, 29, 3, 50, 7, tzinfo=UTC))
self.assertEqual(snapshots[0].extra['created'], "2012-02-29T03:50:07Z")
self.assertEqual(snapshots[0].extra['name'], 'snap-001')
+ self.assertEqual(snapshots[0].name, 'snap-001')
self.assertEqual(snapshots[0].state, VolumeSnapshotState.AVAILABLE)
# invalid date is parsed as None
[2/2] libcloud git commit: Lint for GCE Closes #867
Posted by an...@apache.org.
Lint for GCE
Closes #867
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/b93d0053
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/b93d0053
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/b93d0053
Branch: refs/heads/trunk
Commit: b93d005388e1c136c167e74785fe9f27f25a0bd2
Parents: 6395d62
Author: Allard Hoeve <al...@gmail.com>
Authored: Fri Sep 23 16:58:28 2016 +0200
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri Sep 30 15:37:02 2016 +1000
----------------------------------------------------------------------
libcloud/compute/drivers/gce.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/b93d0053/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index e9e5471..6b00491 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -710,7 +710,8 @@ class GCESnapshot(VolumeSnapshot):
def __init__(self, id, name, size, status, driver, extra=None,
created=None):
self.status = status
- super(GCESnapshot, self).__init__(id, driver, size, extra, created, name=name)
+ super(GCESnapshot, self).__init__(id, driver, size, extra,
+ created, name=name)
class GCETargetHttpProxy(UuidMixin):