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/06/14 12:52:23 UTC
[12/21] libcloud git commit: Updated DigitalOceanNodeDriver -
Consistency in v2 for attributes -> json request data
Updated DigitalOceanNodeDriver - Consistency in v2 for attributes -> json request data
Signed-off-by: Tomaz Muraus <to...@tomaz.me>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8e16f417
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8e16f417
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8e16f417
Branch: refs/heads/trunk
Commit: 8e16f417d1557fb361b071a1a8c9ada90d8516ee
Parents: 33cbf99
Author: jcastillo2nd <j....@gmail.com>
Authored: Thu May 28 19:27:29 2015 +0000
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Sun Jun 14 18:05:58 2015 +0800
----------------------------------------------------------------------
libcloud/compute/drivers/digitalocean.py | 36 +++++++++++++--------------
1 file changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/8e16f417/libcloud/compute/drivers/digitalocean.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py
index 4f86ce6..05bb61c 100644
--- a/libcloud/compute/drivers/digitalocean.py
+++ b/libcloud/compute/drivers/digitalocean.py
@@ -347,16 +347,16 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
:return: The newly created node.
:rtype: :class:`Node`
"""
- params = {'name': name, 'size': size.name, 'image': image.id,
- 'region': location.id}
+ attr = {'name': name, 'size': size.name, 'image': image.id,
+ 'region': location.id}
if ex_ssh_key_ids:
- params['ssh_keys'] = ex_ssh_key_ids
+ attr['ssh_keys'] = ex_ssh_key_ids
res = self.connection.request('/v2/droplets',
- data=json.dumps(params), method='POST')
+ data=json.dumps(attr), method='POST')
- data = res.object
+ data = res.object['droplet']
# TODO: Handle this in the response class
status = res.object.get('status', 'OK')
if status == 'ERROR':
@@ -364,12 +364,12 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
error_message = res.object.get('error_message', message)
raise ValueError('Failed to create node: %s' % (error_message))
- return self._to_node(data=data['droplet'])
+ return self._to_node(data=data)
def reboot_node(self, node):
- params = {'type': 'reboot'}
+ attr = {'type': 'reboot'}
res = self.connection.request('/v2/droplets/%s/actions' % (node.id),
- data=json.dumps(params), method='POST')
+ data=json.dumps(attr), method='POST')
return res.status == httplib.CREATED
def destroy_node(self, node):
@@ -407,9 +407,9 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
:rtype: ``bool``
"""
- params = {'type': 'snapshot', 'name': name}
+ attr = {'type': 'snapshot', 'name': name}
res = self.connection.request('/v2/droplets/%s/actions' % (node.id),
- data=json.dumps(params), method='POST')
+ data=json.dumps(attr), method='POST')
return res.status == httplib.CREATED
def delete_image(self, image):
@@ -427,21 +427,21 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
return res.status == httplib.NO_CONTENT
def ex_rename_node(self, node, name):
- params = {'type': 'rename', 'name': name}
+ attr = {'type': 'rename', 'name': name}
res = self.connection.request('/v2/droplets/%s/actions' % (node.id),
- data=json.dumps(params), method='POST')
+ data=json.dumps(attr), method='POST')
return res.status == httplib.CREATED
def ex_shutdown_node(self, node):
- params = {'type': 'shutdown'}
+ attr = {'type': 'shutdown'}
res = self.connection.request('/v2/droplets/%s/actions' % (node.id),
- data=json.dumps(params), method='POST')
+ data=json.dumps(attr), method='POST')
return res.status == httplib.CREATED
def ex_power_on_node(self, node):
- params = {'type': 'power_on'}
+ attr = {'type': 'power_on'}
res = self.connection.request('/v2/droplets/%s/actions' % (node.id),
- data=json.dumps(params), method='POST')
+ data=json.dumps(attr), method='POST')
return res.status == httplib.CREATED
def list_key_pairs(self):
@@ -478,9 +478,9 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
:param public_key: Valid public key string (required)
:type public_key: ``str``
"""
- params = {'name': name, 'public_key': public_key}
+ attr = {'name': name, 'public_key': public_key}
res = self.connection.request('/v2/account/keys', method='POST',
- data=json.dumps(params))
+ data=json.dumps(attr))
data = res.object['ssh_key']