You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by qu...@apache.org on 2018/01/29 18:18:19 UTC
[1/3] libcloud git commit: Reduce `tox -e lint` verbosity
Repository: libcloud
Updated Branches:
refs/heads/trunk aaf15742f -> 2a8546d93
Reduce `tox -e lint` verbosity
Closes #1161
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/889a58ac
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/889a58ac
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/889a58ac
Branch: refs/heads/trunk
Commit: 889a58acf9627e55f40c4c0cffdcf92beea29de8
Parents: aaf1574
Author: Quentin Pradet <qu...@apache.org>
Authored: Tue Jan 9 15:45:35 2018 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Jan 29 22:17:44 2018 +0400
----------------------------------------------------------------------
tox.ini | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/889a58ac/tox.ini
----------------------------------------------------------------------
diff --git a/tox.ini b/tox.ini
index 3a681f9..83ba212 100644
--- a/tox.ini
+++ b/tox.ini
@@ -83,7 +83,7 @@ commands = flake8 --ignore=E402 --exclude="test" libcloud/
flake8 --ignore=E402 integration/
flake8 --ignore=E402,E902 docs/examples/
flake8 --ignore=E402,E902 --max-line-length=160 contrib/
- python -mjson.tool libcloud/data/pricing.json
+ python -mjson.tool libcloud/data/pricing.json /dev/null
[testenv:checks]
commands = bash ./scripts/check_file_names.sh
[3/3] libcloud git commit: Add changes for #1169
Posted by qu...@apache.org.
Add changes for #1169
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/2a8546d9
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/2a8546d9
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/2a8546d9
Branch: refs/heads/trunk
Commit: 2a8546d934ef383d99172808c071c6846deff635
Parents: 8fadb9c
Author: Quentin Pradet <qu...@apache.org>
Authored: Mon Jan 29 22:16:33 2018 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Jan 29 22:17:55 2018 +0400
----------------------------------------------------------------------
CHANGES.rst | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/2a8546d9/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index d71af12..abf449c 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -75,6 +75,10 @@ Compute
(LIBCLOUD-967, GITHUB-1149)
[Mike Fischer]
+- [Digital Ocean] Add rebuild and resize commands
+ (LIBCLOUD-977, GITHUB-1169)
+ [Adam Wight]
+
- [EC2] Add new x1.16xlarge and x1e.32xlarge instance type. (GITHUB-1101)
[Anthony Monthe]
[2/3] libcloud git commit: Adds rebuild and resize commands for
DigitalOcean
Posted by qu...@apache.org.
Adds rebuild and resize commands for DigitalOcean
Implement the following DigitalOcean APIs as driver-specific extensions,
* https://developers.digitalocean.com/documentation/v2/#rebuild-a-droplet
* https://developers.digitalocean.com/documentation/v2/#resize-a-droplet
Signed-off-by: Quentin Pradet <qu...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8fadb9c7
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8fadb9c7
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8fadb9c7
Branch: refs/heads/trunk
Commit: 8fadb9c7c9b65993b84d12b63dc6ab8e1277ea24
Parents: 889a58a
Author: Adam Wight <aw...@wikimedia.org>
Authored: Fri Jan 26 13:02:41 2018 -0500
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Jan 29 22:17:55 2018 +0400
----------------------------------------------------------------------
libcloud/compute/drivers/digitalocean.py | 34 ++++++++++++++++++++
.../digitalocean_v2/ex_rebuild_node.json | 12 +++++++
.../digitalocean_v2/ex_resize_node.json | 12 +++++++
libcloud/test/compute/test_digitalocean_v2.py | 25 ++++++++++++++
4 files changed, 83 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/8fadb9c7/libcloud/compute/drivers/digitalocean.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py
index c8acdf0..5815955 100644
--- a/libcloud/compute/drivers/digitalocean.py
+++ b/libcloud/compute/drivers/digitalocean.py
@@ -280,6 +280,40 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
data=json.dumps(attr), method='POST')
return res.status == httplib.CREATED
+ def ex_rebuild_node(self, node):
+ """
+ Destroy and rebuild the node using its base image.
+
+ :param node: Node to rebuild
+ :type node: :class:`Node`
+
+ :return True if the operation began successfully
+ :rtype ``bool``
+ """
+ attr = {'type': 'rebuild', 'image': node.extra['image']['id']}
+ res = self.connection.request('/v2/droplets/%s/actions' % (node.id),
+ data=json.dumps(attr), method='POST')
+ return res.status == httplib.CREATED
+
+ def ex_resize_node(self, node, size):
+ """
+ Resize the node to a different machine size. Note that some resize
+ operations are reversible, and others are irreversible.
+
+ :param node: Node to rebuild
+ :type node: :class:`Node`
+
+ :param size: New size for this machine
+ :type node: :class:`NodeSize`
+
+ :return True if the operation began successfully
+ :rtype ``bool``
+ """
+ attr = {'type': 'resize', 'size': size.name}
+ res = self.connection.request('/v2/droplets/%s/actions' % (node.id),
+ data=json.dumps(attr), method='POST')
+ return res.status == httplib.CREATED
+
def create_key_pair(self, name, public_key=''):
"""
Create a new SSH key.
http://git-wip-us.apache.org/repos/asf/libcloud/blob/8fadb9c7/libcloud/test/compute/fixtures/digitalocean_v2/ex_rebuild_node.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/ex_rebuild_node.json b/libcloud/test/compute/fixtures/digitalocean_v2/ex_rebuild_node.json
new file mode 100644
index 0000000..154ddce
--- /dev/null
+++ b/libcloud/test/compute/fixtures/digitalocean_v2/ex_rebuild_node.json
@@ -0,0 +1,12 @@
+{
+ "action": {
+ "id": 36804758,
+ "status": "in-progress",
+ "type": "rebuild",
+ "started_at": "2014-11-14T16:31:19Z",
+ "completed_at": null,
+ "resource_id": 3164450,
+ "resource_type": "droplet",
+ "region_slug": "nyc3"
+ }
+}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/8fadb9c7/libcloud/test/compute/fixtures/digitalocean_v2/ex_resize_node.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/ex_resize_node.json b/libcloud/test/compute/fixtures/digitalocean_v2/ex_resize_node.json
new file mode 100644
index 0000000..94f5f0c
--- /dev/null
+++ b/libcloud/test/compute/fixtures/digitalocean_v2/ex_resize_node.json
@@ -0,0 +1,12 @@
+{
+ "action": {
+ "id": 36804758,
+ "status": "in-progress",
+ "type": "resize",
+ "started_at": "2014-11-14T16:31:19Z",
+ "completed_at": null,
+ "resource_id": 3164450,
+ "resource_type": "droplet",
+ "region_slug": "nyc3"
+ }
+}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/8fadb9c7/libcloud/test/compute/test_digitalocean_v2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_digitalocean_v2.py b/libcloud/test/compute/test_digitalocean_v2.py
index c0065e7..1b049f9 100644
--- a/libcloud/test/compute/test_digitalocean_v2.py
+++ b/libcloud/test/compute/test_digitalocean_v2.py
@@ -155,6 +155,19 @@ class DigitalOcean_v2_Tests(LibcloudTestCase):
result = self.driver.ex_hard_reboot(node)
self.assertTrue(result)
+ def test_ex_rebuild_node_success(self):
+ node = self.driver.list_nodes()[0]
+ DigitalOceanMockHttp.type = 'REBUILD'
+ result = self.driver.ex_rebuild_node(node)
+ self.assertTrue(result)
+
+ def test_ex_resize_node_success(self):
+ node = self.driver.list_nodes()[0]
+ size = self.driver.list_sizes()[0]
+ DigitalOceanMockHttp.type = 'RESIZE'
+ result = self.driver.ex_resize_node(node, size)
+ self.assertTrue(result)
+
def test_destroy_node_success(self):
node = self.driver.list_nodes()[0]
DigitalOceanMockHttp.type = 'DESTROY'
@@ -362,6 +375,18 @@ class DigitalOceanMockHttp(MockHttp):
body = self.fixtures.load('ex_hard_reboot.json')
return (httplib.CREATED, body, {}, httplib.responses[httplib.OK])
+ def _v2_droplets_3164444_actions_REBUILD(self, method, url,
+ body, headers):
+ # ex_rebuild_node
+ body = self.fixtures.load('ex_rebuild_node.json')
+ return (httplib.CREATED, body, {}, httplib.responses[httplib.OK])
+
+ def _v2_droplets_3164444_actions_RESIZE(self, method, url,
+ body, headers):
+ # ex_resize_node
+ body = self.fixtures.load('ex_resize_node.json')
+ return (httplib.CREATED, body, {}, httplib.responses[httplib.OK])
+
def _v2_account_keys(self, method, url, body, headers):
body = self.fixtures.load('list_key_pairs.json')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])