From 6b492de1ee1e75c3e1a659cfa1369fe137d1e4cc Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 12 Mar 2014 20:45:51 -0500 Subject: [PATCH] Fix regression in dnsmadeeasy module caused by fetch_url change Also: * changed this module to use https for requests to the API * fixed a bug in which a traceback was caused when the domain wasn't found Fixes #6457 --- net_infrastructure/dnsmadeeasy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net_infrastructure/dnsmadeeasy b/net_infrastructure/dnsmadeeasy index 6b4fe1dcdb5..148e25a5011 100644 --- a/net_infrastructure/dnsmadeeasy +++ b/net_infrastructure/dnsmadeeasy @@ -129,7 +129,7 @@ class DME2: self.api = apikey self.secret = secret - self.baseurl = 'http://api.dnsmadeeasy.com/V2.0/' + self.baseurl = 'https://api.dnsmadeeasy.com/V2.0/' self.domain = str(domain) self.domain_map = None # ["domain_name"] => ID self.record_map = None # ["record_name"] => ID @@ -161,14 +161,14 @@ class DME2: if data and not isinstance(data, basestring): data = urllib.urlencode(data) - response, info = fetch_url(self.module, url, data=data, method=method) + response, info = fetch_url(self.module, url, data=data, method=method, headers=self._headers()) if info['status'] not in (200, 201, 204): self.module.fail_json(msg="%s returned %s, with body: %s" % (url, info['status'], info['msg'])) try: return json.load(response) except Exception, e: - return False + return {} def getDomain(self, domain_id): if not self.domain_map: @@ -268,7 +268,7 @@ def main(): domain_records = DME.getRecords() if not domain_records: module.fail_json( - msg="The %s domain name is not accessible with this api_key; try using its ID if known." % domain) + msg="The requested domain name is not accessible with this api_key; try using its ID if known.") module.exit_json(changed=False, result=domain_records) # Fetch existing record + Build new one