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

adds dns support for ns1 provider #710

Closed
wants to merge 16 commits into from
Closed

adds dns support for ns1 provider #710

wants to merge 16 commits into from

Conversation

piratimir
Copy link
Contributor

The methods that deal with records are not finished yet.

@tonybaloney
Copy link
Contributor

Thanks @jetbird for the PR. Let me know when this is completed. Also if you install flake8 locally you can run the code checks to pass the failing lint build job in travis.

@piratimir
Copy link
Contributor Author

@tonybaloney @Kami I think we have a problem in implementing the def create_record(self, name, zone, type, data, extra=None) method. From what I understand when reading the API, the provider does not support adding a name for the new record.

Under Records take a look on the PUT method https://ns1.com/api/

@Kami
Copy link
Member

Kami commented Feb 23, 2016

@jetbird I checked the docs and it looks like you need to provide a fully qualified record name when creating a record.

This means record name + domain name. It looks like that in the docs they refer to the record name + domainname as "domain".

For example if record name is foo and domain name is example.com you would need to pass example.com for the zone and foo.example.com for domain.

@piratimir
Copy link
Contributor Author

@Kami, you are right. Coding it now.

@piratimir
Copy link
Contributor Author

@tonybaloney It is finished man. Please take a look at the code.

@tonybaloney
Copy link
Contributor

@jetbird the lint is failing:
libcloud/common/nsone.py:20:80: E501 line too long (85 > 79 characters)
libcloud/common/nsone.py:23:80: E501 line too long (88 > 79 characters)
libcloud/dns/drivers/nsone.py:7:80: E501 line too long (80 > 79 characters)
libcloud/dns/drivers/nsone.py:8:80: E501 line too long (114 > 79 characters)
libcloud/dns/drivers/nsone.py:60:80: E501 line too long (90 > 79 characters)
libcloud/dns/drivers/nsone.py:79:80: E501 line too long (115 > 79 characters)
libcloud/dns/drivers/nsone.py:90:80: E501 line too long (91 > 79 characters)
libcloud/dns/drivers/nsone.py:93:80: E501 line too long (90 > 79 characters)
libcloud/dns/drivers/nsone.py:129:80: E501 line too long (90 > 79 characters)
libcloud/dns/drivers/nsone.py:132:80: E501 line too long (85 > 79 characters)
libcloud/dns/drivers/nsone.py:138:80: E501 line too long (92 > 79 characters)
libcloud/dns/drivers/nsone.py:140:80: E501 line too long (80 > 79 characters)
libcloud/dns/drivers/nsone.py:149:80: E501 line too long (96 > 79 characters)
libcloud/dns/drivers/nsone.py:164:80: E501 line too long (86 > 79 characters)
libcloud/dns/drivers/nsone.py:169:80: E501 line too long (96 > 79 characters)
libcloud/dns/drivers/nsone.py:189:80: E501 line too long (90 > 79 characters)
libcloud/dns/drivers/nsone.py:205:80: E501 line too long (91 > 79 characters)
libcloud/dns/drivers/nsone.py:208:80: E501 line too long (90 > 79 characters)
libcloud/dns/drivers/nsone.py:230:80: E501 line too long (90 > 79 characters)
libcloud/dns/drivers/nsone.py:243:80: E501 line too long (92 > 79 characters)
libcloud/dns/drivers/nsone.py:246:80: E501 line too long (89 > 79 characters)
libcloud/dns/drivers/nsone.py:277:80: E501 line too long (113 > 79 characters)

@piratimir
Copy link
Contributor Author

@tonybaloney I managed to flake8 the code.

@Kami
Copy link
Member

Kami commented Feb 28, 2016

@jetbird Nice work so far 👍

The next step would be adding some tests and documentation :)

common_attr = ['zone', 'id', 'type']
extra = {}
for key in item:
if key not in common_attr:
Copy link
Member

Choose a reason for hiding this comment

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

I believe this should be if key in common_attr (dropping not)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a key is not in common_attr list then we add it in the extra dict as a key with the item.get('key') as value. The keys in common_attr are needed to build the Zone object. Why do you think we should drop it?

@piratimir
Copy link
Contributor Author

@Kami @tonybaloney guys did you find some time to check the tests?


from libcloud.test import MockHttp
from libcloud.test.file_fixtures import DNSFileFixtures
from libcloud.test.secrets import DNS_PARAMS_NSONE
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not exist, you need to update test/secrets-dist.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tonybaloney I thought DNS_PARAMS_NSONE is supposed to stay locally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tonybaloney I updated and pushed secrets.py. I do not know why the travis builds are failing. The tests pass when run on my local machine.

@tonybaloney
Copy link
Contributor

@jetbird secrets.py is on the ignore list, part of the build is to copy secrets-dist.py to secrets.py. You need to apply your changes to secrets-dist and apply those changes. Not secrets.py

@piratimir
Copy link
Contributor Author

@tonybaloney Done.

@tonybaloney
Copy link
Contributor

Excellent, thats the one. If CI gives the 🍏 then I will merge. LGTM

@piratimir
Copy link
Contributor Author

@tonybaloney It does not look like that. I also updated the fixtures with blank lines at each one of them, but when pushing on github they get ignored.

@tonybaloney
Copy link
Contributor

@jetbird except NsOneException, e: is not a valid syntax in Python 3.

Do you have Tox? This would really help you testing before you commit.

@piratimir
Copy link
Contributor Author

@tonybaloney I will install it now.

@piratimir
Copy link
Contributor Author

@tonybaloney I installed tox and ran the tests with sudo tox, but the problem is that many interpreters are not found. I am not familiar with tox, so I guess I need to read the docs. Where should I install these interpreters?

Is the following the only problem or are there more. Because if it is the only one I can fix this and take care later about the tox?

except NsOneException, e: is not a valid syntax in Python 3.

@tonybaloney
Copy link
Contributor

@jetbird you can review the errors here https://travis-ci.org/apache/libcloud/builds/116256818

@piratimir
Copy link
Contributor Author

@tonybaloney I decided to follow this approach to keep one code base through different versions of python.

  try:
       response = self.connection.request(action=action, method='GET')
  except NsOneException:
       e = sys.exc_info()[1]

Now will try to pass the tests with tox.

@tonybaloney
Copy link
Contributor

Use tox -e py34 as an example to just test 3.4. You don't need to install every possible version, just at least 2.7 and 3.4+.

@piratimir
Copy link
Contributor Author

@tonybaloney I get the following output when running the command.

lostbird@lostbird:~/projects/libcloud$ sudo tox -e py34
GLOB sdist-make: /home/lostbird/projects/libcloud/setup.py
py34 create: /home/lostbird/projects/libcloud/.tox/py34
ERROR: InterpreterNotFound: 
____________________________________________________________________________ summary _____________________________________________________________________________
ERROR:   py34: InterpreterNotFound: 

@piratimir
Copy link
Contributor Author

@tonybaloney I managed to run the tests against python3.4 and they pass. The only check that is failing on travis is the lint check. Maybe it is the fixtures, I have no idea. Thanks for being so patient and helping.

https://travis-ci.org/apache/libcloud/builds/116270772

@piratimir
Copy link
Contributor Author

@Kami @tonybaloney Hey guys when using flake8 on nsone module and test_nsone I do not get any errors. Why do you think the lint build job in travis is failing?

@piratimir
Copy link
Contributor Author

@tonybaloney @Kami any update on this please?

from libcloud.dns.drivers.nsone import NsOneDNSDriver
from libcloud.utils.py3 import httplib
from libcloud.dns.types import ZoneDoesNotExistError, ZoneAlreadyExistsError,\
RecordDoesNotExistError, RecordType
Copy link
Contributor

Choose a reason for hiding this comment

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

There are 2 spaces after the comma. this is failing the lint. remove one of the spaces and just commit that change then we're good to go @jetbird

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok man :) 👍

@piratimir
Copy link
Contributor Author

@tonybaloney I removed the extra spaces, but it still fails.

@tonybaloney
Copy link
Contributor

@jetbird so close!! libcloud/test/dns/test_nsone.py:10:2: E121 continuation line under-indented for hanging indent

@tonybaloney
Copy link
Contributor

yeah!!

@piratimir
Copy link
Contributor Author

@tonybaloney finally 👯

@asfgit asfgit closed this in 4806a6a Mar 21, 2016
@tonybaloney
Copy link
Contributor

Merged. Thanks @jetbird it might be time to get a Python editor with a built in linter! Try Komodo or Atom :-)

@piratimir
Copy link
Contributor Author

@tonybaloney Thanks for the help and support 👍 I am using pycharm and flake8 is not working ok. I installed pylint via pip. I will be contributing again, so please if you can give me your email address would be great :)

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

3 participants