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:16 UTC
[05/21] libcloud git commit: Implemented
libcloud.dns.driver.digitalocean DigitalOceanDNSDriver.update_record
Implemented libcloud.dns.driver.digitalocean DigitalOceanDNSDriver.update_record
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/66dc7cd1
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/66dc7cd1
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/66dc7cd1
Branch: refs/heads/trunk
Commit: 66dc7cd1f51d598a09594f207c0ccc7abab6443b
Parents: f50b8d4
Author: Javier Castillo II <j....@gmail.com>
Authored: Sat Apr 11 02:30:35 2015 +0000
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Sun Jun 14 18:05:58 2015 +0800
----------------------------------------------------------------------
libcloud/dns/drivers/digitalocean.py | 57 ++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/66dc7cd1/libcloud/dns/drivers/digitalocean.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/digitalocean.py b/libcloud/dns/drivers/digitalocean.py
index 40357b9..7e70f11 100644
--- a/libcloud/dns/drivers/digitalocean.py
+++ b/libcloud/dns/drivers/digitalocean.py
@@ -183,9 +183,64 @@ class DigitalOceanDNSDriver(DNSDriver):
method='POST')
return Record(id=res.object['domain_record']['id'],
- name=res.object['domain_record']['id'],
+ name=res.object['domain_record']['name'],
type=type, data=data, zone=zone, driver=self, extra=extra)
+ def update_record(self, record, name=None, type=None, data=None, extra=None):
+ """
+ Update an existing record.
+
+ :param record: Record to update.
+ :type record: :class:`Record`
+
+ :param name: Record name without the domain name (e.g. www). (Ignored)
+ Note: The value is pulled from the record being updated
+ :type name: ``str``
+
+ :param type: DNS record type (A, AAAA, ...). (Ignored)
+ Note: Updating records does not support changing type
+ so this value is ignored
+ :type type: :class:`RecordType`
+
+ :param data: Data for the record (depends on the record type).
+ :type data: ``str``
+
+ :param extra: (optional) Extra attributes (driver specific).
+ :type extra: ``dict``
+
+ :rtype: :class:`Record`
+ """
+ params = {
+ "type" : record.type,
+ "name" : record.name,
+ "data" : data
+ }
+ if data == None:
+ params['data'] = record.data
+ if extra:
+ try:
+ params['priority'] = extra['priority']
+ except KeyError:
+ params['priority'] = 'null'
+ try:
+ params['port'] = extra['port']
+ except KeyError:
+ params['port'] = 'null'
+ try:
+ params['weight'] = extra['weight']
+ except KeyError:
+ params['weight'] = 'null'
+
+ res = self.connection.request('/v2/domains/%s/records/%s' %
+ (record.zone.id, record.id),
+ params=params,
+ method='PUT')
+
+ return Record(id=res.object['domain_record']['id'],
+ name=res.object['domain_record']['name'],
+ type=record.type, data=data, zone=record.zone,
+ driver=self, extra=extra)
+
def delete_zone(self, zone):
"""
Delete a zone.