Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIBCLOUD-772 driver class for GoDaddy DNS #640

Closed

Conversation

tonybaloney
Copy link
Contributor

  • Implement driver methods
  • Document usage and examples
  • Add tests and responses based on developer.godaddy.com

tonybaloney added 2 commits Nov 24, 2015
Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>
Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>
@Kami
Copy link
Member

Kami commented Nov 25, 2015

As far as test fixtures go - I would recommend to use actual responses you get back when talking to the API.

Maybe times before we encountered an issue with out of date or incorrect docs (I just encountered that issue with CloudFlare DNS driver a couple of days ago - some of the responses in the docs were incorrect and out of date). Sadly it looks like most of the provider documentation is still written manually and not automatically generated from code.

tonybaloney added 5 commits Nov 27, 2015
…s, add and update records, cancel domains, check availability, validate purchase requests

Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>
Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>
Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>
Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>
Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>
@tonybaloney tonybaloney changed the title [WIP] LIBCLOUD-772 driver class for GoDaddy DNS LIBCLOUD-772 driver class for GoDaddy DNS Nov 27, 2015
@tonybaloney
Copy link
Contributor Author

GoDaddy records don't have IDs, and when you update or query them you combine the name and type, so I turned that into the ID. Just for get_record, for lack of an alternative.

@tonybaloney
Copy link
Contributor Author

@Kami your thoughts please. this is complete now

@Kami
Copy link
Member

Kami commented Nov 27, 2015

GoDaddy records don't have IDs, and when you update or query them you combine the name and type, so I turned that into the ID. Just for get_record, for lack of an alternative.

Yeah, I believe GCE driver does something like that as well.

@tonybaloney
Copy link
Contributor Author

@Kami as per your suggestion i used real API responses for the tests as well. except the "purchase domain" one, that would get expensive

if not self.body:
return None
# json.loads doesn't like the regex expressions used in godaddy schema
self.body = self.body.replace('\\.', '\\\\.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, ok :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.google.com.au/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=json%20loads%20invalid%20escape yeah I'm not the only one. the other option is to introduce cjson, but adding another prereq to the project for just one regex statement seems excessive

Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>
'name': name,
'data': data,
'priority': 1,
'ttl': extra['ttl'] if hasattr(extra, 'ttl') else 5,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed you use hasattr. This won't work since hasattr only works on class instances. For dictionaries you should either use key in dict or dict.get(key, default_value).

@Kami
Copy link
Member

Kami commented Nov 27, 2015

Thanks.

Added some comments.

@Kami
Copy link
Member

Kami commented Nov 27, 2015

Ah, you are fast! :)

tonybaloney added 3 commits Nov 27, 2015
* added method for _format_record to avoid DRY in create and update record
* raise record does not exist error

Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>
…ords

Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>
@tonybaloney
Copy link
Contributor Author

  • fix string interpolation for python 2,5
  • merge ttl update and use new record type
  • wrap string formats in parenthesis
  • create method to format a new record request for create and update record
  • dont use hasattr
  • use proper equality comparer
  • create utility method for format id of record
  • throw record does not exist error

@tonybaloney
Copy link
Contributor Author

ok @Kami done. very thorough code review!

if extra is None:
extra = {}
new_record = {}
if type is RecordType.SRV:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, should also use ==.

@Kami
Copy link
Member

Kami commented Nov 27, 2015

A couple of more things.

Besides that, LGTM, +1

@asfgit asfgit closed this in d4fba98 Nov 27, 2015
@Kami
Copy link
Member

Kami commented Feb 23, 2016

It appears that this driver never worked - https://stackoverflow.com/questions/35553386/apache-libcloud-dns-and-godaddy-name-or-service-not-known

I pushed a fix in a3ba6a4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants