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/10/11 00:39:41 UTC
[1/5] libcloud git commit: Added OVH compute snapshot management
Repository: libcloud
Updated Branches:
refs/heads/trunk 6dce592b0 -> 26671fbd7
Added OVH compute snapshot management
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/4f7bc9c7
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/4f7bc9c7
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/4f7bc9c7
Branch: refs/heads/trunk
Commit: 4f7bc9c74f1bd24c2f034450567d7ac37e62024d
Parents: 9ebc0b4
Author: ZuluPro <mo...@hotmail.com>
Authored: Sun Oct 9 13:22:22 2016 -0400
Committer: ZuluPro <mo...@hotmail.com>
Committed: Sun Oct 9 13:22:22 2016 -0400
----------------------------------------------------------------------
libcloud/compute/drivers/ovh.py | 77 ++++++++++++++++++++++++++++++++++--
1 file changed, 74 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/4f7bc9c7/libcloud/compute/drivers/ovh.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ovh.py b/libcloud/compute/drivers/ovh.py
index 3043835..6d1ee51 100644
--- a/libcloud/compute/drivers/ovh.py
+++ b/libcloud/compute/drivers/ovh.py
@@ -15,10 +15,12 @@
"""
Ovh driver
"""
+from libcloud.utils.py3 import httplib
from libcloud.common.ovh import API_ROOT, OvhConnection
-from libcloud.compute.base import NodeDriver, NodeSize, Node, NodeLocation
-from libcloud.compute.base import NodeImage, StorageVolume
-from libcloud.compute.types import Provider, StorageVolumeState
+from libcloud.compute.base import (NodeDriver, NodeSize, Node, NodeLocation,
+ NodeImage, StorageVolume, VolumeSnapshot)
+from libcloud.compute.types import (Provider, StorageVolumeState,
+ VolumeSnapshotState)
from libcloud.compute.drivers.openstack import OpenStackNodeDriver
from libcloud.compute.drivers.openstack import OpenStackKeyPair
@@ -40,6 +42,7 @@ class OvhNodeDriver(NodeDriver):
NODE_STATE_MAP = OpenStackNodeDriver.NODE_STATE_MAP
VOLUME_STATE_MAP = OpenStackNodeDriver.VOLUME_STATE_MAP
+ SNAPSHOT_STATE_MAP = OpenStackNodeDriver.SNAPSHOT_STATE_MAP
def __init__(self, key, secret, ex_project_id, ex_consumer_key=None):
"""
@@ -374,6 +377,56 @@ class OvhNodeDriver(NodeDriver):
self.connection.request(action, data=data, method='POST')
return True
+ def ex_list_snapshots(self, location=None):
+ action = self._get_project_action('volume/snapshot')
+ params = {}
+ if location:
+ params['region'] = location.id
+ response = self.connection.request(action, params=params)
+ return self._to_snapshots(response.object)
+
+ def ex_get_volume_snapshot(self, snapshot_id):
+ action = self._get_project_action('volume/snapshot/%s' % snapshot_id)
+ response = self.connection.request(action)
+ return self._to_snapshot(response.object)
+
+ def list_volume_snapshots(self, volume):
+ action = self._get_project_action('volume/snapshot')
+ params = {'region': volume.extra['region']}
+ response = self.connection.request(action, params=params)
+ snapshots = self._to_snapshots(response.object)
+ return [snap for snap in snapshots
+ if snap.extra['volume_id'] == volume.id]
+
+ def create_volume_snapshot(self, volume, name=None, ex_description=None):
+ """
+ Create snapshot from volume
+
+ :param volume: Instance of `StorageVolume`
+ :type volume: `StorageVolume`
+
+ :param name: Name of snapshot (optional)
+ :type name: `str` | `NoneType`
+
+ :param ex_description: Description of the snapshot (optional)
+ :type ex_description: `str` | `NoneType`
+
+ :rtype: :class:`VolumeSnapshot`
+ """
+ action = self._get_project_action('volume/%s/snapshot/' % volume.id)
+ data = {}
+ if name:
+ data['name'] = name
+ if ex_description:
+ data['description'] = ex_description
+ response = self.connection.request(action, data=data, method='POST')
+ return self._to_snapshot(response.object)
+
+ def destroy_volume_snapshot(self, snapshot):
+ action = self._get_project_action('volume/snapshot/%s' % snapshot.id)
+ response = self.connection.request(action, method='DELETE')
+ return response.status == httplib.OK
+
def _to_volume(self, obj):
extra = obj.copy()
extra.pop('id')
@@ -434,5 +487,23 @@ class OvhNodeDriver(NodeDriver):
def _to_key_pairs(self, objs):
return [self._to_key_pair(obj) for obj in objs]
+ def _to_snapshot(self, obj):
+ extra = {
+ 'volume_id': obj['volumeId'],
+ 'region': obj['region'],
+ 'description': obj['description'],
+ 'status': obj['status'],
+ }
+ state = self.SNAPSHOT_STATE_MAP.get(obj['status'],
+ VolumeSnapshotState.UNKNOWN)
+ snapshot = VolumeSnapshot(id=obj['id'], driver=self,
+ size=obj['size'], extra=extra,
+ created=obj['creationDate'], state=state,
+ name=obj['name'])
+ return snapshot
+
+ def _to_snapshots(self, objs):
+ return [self._to_snapshot(obj) for obj in objs]
+
def _ex_connection_class_kwargs(self):
return {'ex_consumer_key': self.consumer_key}
[2/5] libcloud git commit: Added OVH snapshot tests
Posted by an...@apache.org.
Added OVH snapshot tests
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/e4f124e2
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/e4f124e2
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/e4f124e2
Branch: refs/heads/trunk
Commit: e4f124e27194606220462ef4968f8b6885c2ebd7
Parents: 4f7bc9c
Author: ZuluPro <mo...@hotmail.com>
Authored: Sun Oct 9 13:23:09 2016 -0400
Committer: ZuluPro <mo...@hotmail.com>
Committed: Sun Oct 9 22:22:31 2016 -0400
----------------------------------------------------------------------
.../fixtures/ovh/volume_snapshot_get.json | 22 ++++++++++++
.../ovh/volume_snapshot_get_details.json | 10 ++++++
libcloud/test/compute/test_ovh.py | 38 ++++++++++++++++++++
3 files changed, 70 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/e4f124e2/libcloud/test/compute/fixtures/ovh/volume_snapshot_get.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/ovh/volume_snapshot_get.json b/libcloud/test/compute/fixtures/ovh/volume_snapshot_get.json
new file mode 100644
index 0000000..a96446a
--- /dev/null
+++ b/libcloud/test/compute/fixtures/ovh/volume_snapshot_get.json
@@ -0,0 +1,22 @@
+[
+ {
+ "volumeId": "foo",
+ "status": "available",
+ "region": "GRA1",
+ "name": "",
+ "description": "",
+ "size": 10,
+ "creationDate": "2016-10-10T17:33:02Z",
+ "id": "foo-snap"
+ },
+ {
+ "volumeId": "bar",
+ "status": "available",
+ "region": "GRA1",
+ "name": "",
+ "description": "",
+ "size": 10,
+ "creationDate": "2016-10-09T17:33:02Z",
+ "id": "bar-snap"
+ }
+]
http://git-wip-us.apache.org/repos/asf/libcloud/blob/e4f124e2/libcloud/test/compute/fixtures/ovh/volume_snapshot_get_details.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/ovh/volume_snapshot_get_details.json b/libcloud/test/compute/fixtures/ovh/volume_snapshot_get_details.json
new file mode 100644
index 0000000..63eb4d6
--- /dev/null
+++ b/libcloud/test/compute/fixtures/ovh/volume_snapshot_get_details.json
@@ -0,0 +1,10 @@
+{
+ "volumeId": "foo",
+ "status": "available",
+ "region": "GRA1",
+ "name": "",
+ "description": "",
+ "size": 10,
+ "creationDate": "2016-10-10T17:33:02Z",
+ "id": "foo-snap"
+}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/e4f124e2/libcloud/test/compute/test_ovh.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ovh.py b/libcloud/test/compute/test_ovh.py
index 8f30687..f434f7a 100644
--- a/libcloud/test/compute/test_ovh.py
+++ b/libcloud/test/compute/test_ovh.py
@@ -107,6 +107,25 @@ class OvhMockHttp(BaseOvhMockHttp):
body = self.fixtures.load('volume_get_detail.json')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+ def _json_1_0_cloud_project_project_id_volume_snapshot_region_SBG_1_get(self, method, url, body, headers):
+ body = self.fixtures.load('volume_snapshot_get.json')
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+ def _json_1_0_cloud_project_project_id_volume_snapshot_get(self, method, url, body, headers):
+ body = self.fixtures.load('volume_snapshot_get.json')
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+ def _json_1_0_cloud_project_project_id_volume_snapshot_foo_get(self, method, url, body, headers):
+ body = self.fixtures.load('volume_snapshot_get_details.json')
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+ def _json_1_0_cloud_project_project_id_volume_snapshot_foo_snap_delete(self, method, url, body, headers):
+ return (httplib.OK, None, {}, httplib.responses[httplib.OK])
+
+ def _json_1_0_cloud_project_project_id_volume_foo_snapshot__post(self, method, url, body, headers):
+ body = self.fixtures.load('volume_snapshot_get_details.json')
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
@patch('libcloud.common.ovh.OvhConnection._timedelta', 42)
class OvhTests(unittest.TestCase):
@@ -201,5 +220,24 @@ class OvhTests(unittest.TestCase):
response = self.driver.detach_volume(ex_node=node, volume=volume)
self.assertTrue(response)
+ def test_ex_list_snapshots(self):
+ self.driver.ex_list_snapshots()
+
+ def test_ex_get_volume_snapshot(self):
+ self.driver.ex_get_volume_snapshot('foo')
+
+ def test_list_volume_snapshots(self):
+ volume = self.driver.ex_get_volume('foo')
+ self.driver.list_volume_snapshots(volume)
+
+ def test_create_volume_snapshot(self):
+ volume = self.driver.ex_get_volume('foo')
+ self.driver.create_volume_snapshot(volume)
+
+ def test_destroy_volume_snapshot(self):
+ snapshot = self.driver.ex_get_volume_snapshot('foo')
+ result = self.driver.destroy_volume_snapshot(snapshot)
+ self.assertTrue(result)
+
if __name__ == '__main__':
sys.exit(unittest.main())
[4/5] libcloud git commit: Merge branch 'libcloud-897' into trunk
Closes #897
Posted by an...@apache.org.
Merge branch 'libcloud-897' into trunk
Closes #897
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/d6d98d04
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/d6d98d04
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/d6d98d04
Branch: refs/heads/trunk
Commit: d6d98d0422256f8f31f1285bf3cce24389d56473
Parents: 6dce592 557fd76
Author: Anthony Shaw <an...@apache.org>
Authored: Tue Oct 11 11:37:44 2016 +1100
Committer: Anthony Shaw <an...@apache.org>
Committed: Tue Oct 11 11:37:44 2016 +1100
----------------------------------------------------------------------
libcloud/compute/drivers/ovh.py | 148 +++++++++++++++----
.../fixtures/ovh/volume_snapshot_get.json | 22 +++
.../ovh/volume_snapshot_get_details.json | 10 ++
libcloud/test/compute/test_ovh.py | 38 +++++
4 files changed, 193 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
[3/5] libcloud git commit: OVH - Improved docstring and functions
arguments ordering
Posted by an...@apache.org.
OVH - Improved docstring and functions arguments ordering
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/557fd767
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/557fd767
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/557fd767
Branch: refs/heads/trunk
Commit: 557fd7674b8982c00479c98687231fda3a8e478e
Parents: e4f124e
Author: ZuluPro <mo...@hotmail.com>
Authored: Sun Oct 9 23:49:28 2016 -0400
Committer: ZuluPro <mo...@hotmail.com>
Committed: Sun Oct 9 23:49:28 2016 -0400
----------------------------------------------------------------------
libcloud/compute/drivers/ovh.py | 71 +++++++++++++++++++++++++-----------
1 file changed, 49 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/557fd767/libcloud/compute/drivers/ovh.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ovh.py b/libcloud/compute/drivers/ovh.py
index 6d1ee51..bfde411 100644
--- a/libcloud/compute/drivers/ovh.py
+++ b/libcloud/compute/drivers/ovh.py
@@ -196,44 +196,44 @@ class OvhNodeDriver(NodeDriver):
data = self.connection.request(action)
return self._to_locations(data.object)
- def list_key_pairs(self, location=None):
+ def list_key_pairs(self, ex_location=None):
"""
List available SSH public keys.
- :keyword location: Location (region) used as filter
- :type location: :class:`NodeLocation`
+ :keyword ex_location: Location (region) used as filter
+ :type ex_location: :class:`NodeLocation`
:return: Public keys
:rtype: ``list``of :class:`KeyPair`
"""
action = self._get_project_action('sshkey')
params = {}
- if location:
- params['region'] = location.id
+ if ex_location:
+ params['region'] = ex_location.id
response = self.connection.request(action, params=params)
return self._to_key_pairs(response.object)
- def get_key_pair(self, name, location):
+ def get_key_pair(self, name, ex_location=None):
"""
Get an individual SSH public key by its name and location.
- :keyword name: SSH key name
- :type name: str
+ :param name: Name of the key pair to retrieve.
+ :type name: ``str``
- :keyword location: Key's region
- :type location: :class:`NodeLocation`
+ :keyword ex_location: Key's region
+ :type ex_location: :class:`NodeLocation`
:return: Public key
:rtype: :class:`KeyPair`
"""
# Keys are indexed with ID
- keys = [key for key in self.list_key_pairs(location)
+ keys = [key for key in self.list_key_pairs(ex_location)
if key.name == name]
if not keys:
raise Exception("No key named '%s'" % name)
return keys[0]
- def import_key_pair_from_string(self, name, key_material, location):
+ def import_key_pair_from_string(self, name, key_material, ex_location):
"""
Import a new public key from string.
@@ -243,11 +243,18 @@ class OvhNodeDriver(NodeDriver):
:param key_material: Public key material.
:type key_material: ``str``
+ :param ex_location: Location where to store the key
+ :type ex_location: :class:`NodeLocation`
+
:return: Imported key pair object.
:rtype: :class:`KeyPair`
"""
action = self._get_project_action('sshkey')
- data = {'name': name, 'publicKey': key_material, 'region': location.id}
+ data = {
+ 'name': name,
+ 'publicKey': key_material,
+ 'region': ex_location.id
+ }
response = self.connection.request(action, data=data, method='POST')
return self._to_key_pair(response.object)
@@ -257,7 +264,7 @@ class OvhNodeDriver(NodeDriver):
self.connection.request(action, params=params, method='DELETE')
return True
- def create_volume(self, size, location, name=None,
+ def create_volume(self, size, name, location, snapshot=None,
ex_volume_type='classic', ex_description=None):
"""
Create a volume.
@@ -268,9 +275,13 @@ class OvhNodeDriver(NodeDriver):
:param name: Name of volume to create
:type name: ``str``
- :keyword location: Location to create the volume in
+ :param location: Location to create the volume in
:type location: :class:`NodeLocation` or ``None``
+ :param snapshot: Snapshot from which to create the new
+ volume. (optional)
+ :type snapshot: :class:`.VolumeSnapshot`
+
:keyword ex_volume_type: ``'classic'`` or ``'high-speed'``
:type ex_volume_type: ``str``
@@ -282,12 +293,11 @@ class OvhNodeDriver(NodeDriver):
"""
action = self._get_project_action('volume')
data = {
+ 'name': name,
'region': location.id,
'size': size,
'type': ex_volume_type,
}
- if name:
- data['name'] = name
if ex_description:
data['description'] = ex_description
response = self.connection.request(action, data=data, method='POST')
@@ -298,20 +308,20 @@ class OvhNodeDriver(NodeDriver):
self.connection.request(action, method='DELETE')
return True
- def list_volumes(self, location=None):
+ def list_volumes(self, ex_location=None):
"""
Return a list of volumes.
- :keyword location: Location use for filter
- :type location: :class:`NodeLocation` or ``None``
+ :keyword ex_location: Location used to filter
+ :type ex_location: :class:`NodeLocation` or ``None``
:return: A list of volume objects.
:rtype: ``list`` of :class:`StorageVolume`
"""
action = self._get_project_action('volume')
data = {}
- if location:
- data['region'] = location.id
+ if ex_location:
+ data['region'] = ex_location.id
response = self.connection.request(action, data=data)
return self._to_volumes(response.object)
@@ -378,6 +388,14 @@ class OvhNodeDriver(NodeDriver):
return True
def ex_list_snapshots(self, location=None):
+ """
+ List all snapshots.
+
+ :keyword location: Location used to filter
+ :type location: :class:`NodeLocation` or ``None``
+
+ :rtype: ``list`` of :class:`VolumeSnapshot`
+ """
action = self._get_project_action('volume/snapshot')
params = {}
if location:
@@ -386,6 +404,15 @@ class OvhNodeDriver(NodeDriver):
return self._to_snapshots(response.object)
def ex_get_volume_snapshot(self, snapshot_id):
+ """
+ Returns a single volume snapshot.
+
+ :param snapshot_id: Node to run the task on.
+ :type snapshot_id: ``str``
+
+ :rtype :class:`.VolumeSnapshot`:
+ :return: Volume snapshot.
+ """
action = self._get_project_action('volume/snapshot/%s' % snapshot_id)
response = self.connection.request(action)
return self._to_snapshot(response.object)
[5/5] libcloud git commit: Changes for #897
Posted by an...@apache.org.
Changes for #897
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/26671fbd
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/26671fbd
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/26671fbd
Branch: refs/heads/trunk
Commit: 26671fbd77ffab1ba9dbc3cb43bdd92e02b0e3a2
Parents: d6d98d0
Author: Anthony Shaw <an...@apache.org>
Authored: Tue Oct 11 11:39:18 2016 +1100
Committer: Anthony Shaw <an...@apache.org>
Committed: Tue Oct 11 11:39:25 2016 +1100
----------------------------------------------------------------------
CHANGES.rst | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/26671fbd/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 4a56a4b..38fd531 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,9 +1,20 @@
\ufeffChangelog
=========
+
Changes in current version of Apache Libcloud
---------------------------------------------
+Compute
+~~~~~~~
+
+- Added snapshot management to OVH compute
+ (GITHUB-897)
+ [Anthony Monthe]
+
+Changes in Apache Libcloud 1.3.0
+--------------------------------
+
General
~~~~~~~