adding dns support for dnspod provider #787
Conversation
Great, thanks. Is the PR already for a review, or are you still working on it? |
@Kami the pr is ready for review :) |
url, body, headers): | ||
body = self.fixtures.load('delete_record_record_does_not_exist.json') | ||
|
||
return httplib.OK, body, {}, httplib.responses[httplib.OK] |
Kami
May 16, 2016
Member
Just curious - does API indeed return 200 status code for all the different responses?
Just curious - does API indeed return 200 status code for all the different responses?
@@ -0,0 +1,65 @@ | |||
from libcloud.common.base import ConnectionKey, JsonResponse |
Kami
May 16, 2016
Member
Please add a missing Apache license header.
Please add a missing Apache license header.
def add_default_headers(self, headers): | ||
headers['Content-Type'] = 'application/x-www-form-urlencoded' | ||
headers['Accept'] = 'text/json' | ||
headers['User-Agent'] = \ |
Kami
May 16, 2016
Member
Please remove this, libcloud includes it's own custom User-Agent header (it includes version of Libcloud and driver user).
Please remove this, libcloud includes it's own custom User-Agent header (it includes version of Libcloud and driver user).
|
||
def list_zones(self): | ||
action = '/Domain.List' | ||
data = {'user_token': self.key, 'format': 'json'} |
Kami
May 16, 2016
Member
user_token
and format
attributes seem to be included in every request so you could maybe refactor this a bit and include those attributes somewhere else (e.g. inside the connection request
method or similar) so the same piece of code doesn't need to be repeated all over.
user_token
and format
attributes seem to be included in every request so you could maybe refactor this a bit and include those attributes somewhere else (e.g. inside the connection request
method or similar) so the same piece of code doesn't need to be repeated all over.
jetbird
May 20, 2016
•
Author
Contributor
@Kami hey man any update on this? I have fixed the other problems, this is the only one left.
@Kami hey man any update on this? I have fixed the other problems, this is the only one left.
Kami
May 21, 2016
Member
As mentioned in my comment above, you could refactor that functionality in a custom request
method on the connection class.
You can find a similar example here - https://github.com/apache/libcloud/blob/trunk/libcloud/dns/drivers/cloudflare.py#L106
As mentioned in my comment above, you could refactor that functionality in a custom request
method on the connection class.
You can find a similar example here - https://github.com/apache/libcloud/blob/trunk/libcloud/dns/drivers/cloudflare.py#L106
e = sys.exc_info()[1] | ||
if e.message == 'No domains': | ||
return [] | ||
zones = self._to_zones(items=response.parse_body()['domains']) |
Kami
May 16, 2016
Member
Libcloud already parses the body for you and is available via response.object
attribute.
No need to call parse_body
yourself.
Libcloud already parses the body for you and is available via response.object
attribute.
No need to call parse_body
yourself.
data=data) | ||
except DNSPodException: | ||
e = sys.exc_info()[1] | ||
if e.message in ['Domain is exists', |
Kami
May 16, 2016
Member
You could save those messages in a constant, e.g. ZONE_ALREADY_EXISTS_ERROR_MSGS = [ ... ]
.
You could save those messages in a constant, e.g. ZONE_ALREADY_EXISTS_ERROR_MSGS = [ ... ]
.
Thanks I've added some in-line comments. |
@jetbird Did you push your latest changes? Since I don't see any new commits (license header is still missing, etc.). |
@Kami done :) |
creates, removes uneeded default headers, calling response.object instead of response.parse_body
Closes #787 Signed-off-by: Tomaz Muraus <tomaz@tomaz.me>
Closes #787 Signed-off-by: Tomaz Muraus <tomaz@tomaz.me>
…ython versions Closes #787 Signed-off-by: Tomaz Muraus <tomaz@tomaz.me>
Closes #787 Signed-off-by: Tomaz Muraus <tomaz@tomaz.me>
Closes #787 Signed-off-by: Tomaz Muraus <tomaz@tomaz.me>
…m creates, removes uneeded default headers, calling response.object instead of response.parse_body Closes #787 Signed-off-by: Tomaz Muraus <tomaz@tomaz.me>
@jetbird Thanks. I've made some changes and fixes (6594a46, defff8a) and merged patch into trunk. As you can see in the second commit (defff8a), |
@jetbird Can you please test latest changes against the live provider API? |
Thanks for explaining the fixes :) Of course, I will test it now. |
@Kami Tested. It works fine for me :) |
@jetbird Great It would also be good if you can add some basic docs for the driver and contact the provider (tall them about Libcloud, driver, etc. and ask them if it's possible to mention it somewhere on the page / docs, etc.). |
DNS support for DNSPod provider
Description
I coded the dns driver for DNSPod on libcloud/dns/drivers/dnspod.py module. In order for this driver to work the libcloud/common/dnspod.py module is needed. The unitttests for this driver are coded in the libcloud/test/dns/test_dnspod.py module.
Status
Checklist (tick everything that applies)