libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From quent...@apache.org
Subject [1/2] libcloud git commit: add ex_enable_ipv6 in DigitalOcean_v2 driver
Date Mon, 16 Oct 2017 07:47:38 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk ef35d3467 -> 29c8eab97


add ex_enable_ipv6 in DigitalOcean_v2 driver

> To enable IPv6 networking on an existing Droplet
> (within a region that has IPv6 available), send
> a POST request to /v2/droplets/$DROPLET_ID/actions.
> Set the "type" attribute to enable_ipv6.

https://developers.digitalocean.com/documentation/v2/

Signed-off-by: Quentin Pradet <quentinp@apache.org>


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

Branch: refs/heads/trunk
Commit: dd98507d783d8a4d3a33a3d2c970377b0b73f34a
Parents: ef35d34
Author: Rick van de Loo <rickvandeloo@gmail.com>
Authored: Sun Oct 15 15:01:02 2017 +0200
Committer: Quentin Pradet <quentinp@apache.org>
Committed: Mon Oct 16 11:44:45 2017 +0400

----------------------------------------------------------------------
 libcloud/compute/drivers/digitalocean.py               |  6 ++++++
 .../fixtures/digitalocean_v2/ex_enable_ipv6.json       | 13 +++++++++++++
 libcloud/test/compute/test_digitalocean_v2.py          | 11 +++++++++++
 3 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/dd98507d/libcloud/compute/drivers/digitalocean.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py
index a9b1e4f..4063c28 100644
--- a/libcloud/compute/drivers/digitalocean.py
+++ b/libcloud/compute/drivers/digitalocean.py
@@ -250,6 +250,12 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
                                       data=json.dumps(attr), method='POST')
         return res.status == httplib.CREATED
 
+    def ex_enable_ipv6(self, node):
+        attr = {'type': 'enable_ipv6'}
+        res = self.connection.request('/v2/droplets/%s/actions' % (node.id),
+                                      data=json.dumps(attr), method='POST')
+        return res.status == httplib.CREATED
+
     def ex_rename_node(self, node, name):
         attr = {'type': 'rename', 'name': name}
         res = self.connection.request('/v2/droplets/%s/actions' % (node.id),

http://git-wip-us.apache.org/repos/asf/libcloud/blob/dd98507d/libcloud/test/compute/fixtures/digitalocean_v2/ex_enable_ipv6.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/ex_enable_ipv6.json b/libcloud/test/compute/fixtures/digitalocean_v2/ex_enable_ipv6.json
new file mode 100644
index 0000000..9386b97
--- /dev/null
+++ b/libcloud/test/compute/fixtures/digitalocean_v2/ex_enable_ipv6.json
@@ -0,0 +1,13 @@
+{
+  "action": {
+    "id": 36804954,
+    "status": "in-progress",
+    "type": "enable_ipv6",
+    "started_at": "2014-11-14T16:34:24Z",
+    "completed_at": null,
+    "resource_id": 3164450,
+    "resource_type": "droplet",
+    "region": "ams2",
+    "region_slug": "ams2"
+  }
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/dd98507d/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 c15dbe7..8589571 100644
--- a/libcloud/test/compute/test_digitalocean_v2.py
+++ b/libcloud/test/compute/test_digitalocean_v2.py
@@ -166,6 +166,12 @@ class DigitalOcean_v2_Tests(LibcloudTestCase):
         result = self.driver.ex_change_kernel(node, 7515)
         self.assertTrue(result)
 
+    def test_ex_enable_ipv6_success(self):
+        node = self.driver.list_nodes()[0]
+        DigitalOceanMockHttp.type = 'ENABLEIPV6'
+        result = self.driver.ex_enable_ipv6(node)
+        self.assertTrue(result)
+
     def test_ex_rename_node_success(self):
         node = self.driver.list_nodes()[0]
         DigitalOceanMockHttp.type = 'RENAME'
@@ -312,6 +318,11 @@ class DigitalOceanMockHttp(MockHttp):
         body = self.fixtures.load('ex_change_kernel.json')
         return (httplib.CREATED, body, {}, httplib.responses[httplib.CREATED])
 
+    def _v2_droplets_3164444_actions_ENABLEIPV6(self, method, url, body, headers):
+        # enable_ipv6
+        body = self.fixtures.load('ex_enable_ipv6.json')
+        return (httplib.CREATED, body, {}, httplib.responses[httplib.CREATED])
+
     def _v2_droplets_3164444_actions_RENAME(self, method, url, body, headers):
         # rename_node
         body = self.fixtures.load('ex_rename_node.json')


Mime
View raw message