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

DNS driver for digitalocean and other minor Node driver updates #505

Closed
wants to merge 19 commits into from
Closed

DNS driver for digitalocean and other minor Node driver updates #505

wants to merge 19 commits into from

Conversation

jcastillo2nd
Copy link
Contributor

  • This includes common.digitalocean with the Node driver using the DigitalOceanBaseDriver
  • DigitalOceanBaseDriver ( and NodeDriver ) will handle v1 and v2 credentials properly
  • DigitalOceanNodeDriver ( for v1 ) implements ( 4 of the ) KeyPair Management instead of using ex_ssh_*
  • DigitalOceanDNSDriver implemented, only with v2 credentials, as v1 will at some point be deprecated so it was not implemented
  • DigitalOceanDNSDriver tests have been created
  • Modified FixtureRoots to include common so that tests for common could use it

I'v run through the DigitalOcean files ( for common, node and dns ) with flake8, and with the exception of 2 tests files, ( with long strings that I don't know how to break up to pass the test AND land within 79 chars ) everything is clean.

I would like to note that the documentation on the KeyPair management may need to be updated to include return types that are consistent with the other components of libcloud. This could be setup in an issue, but at the same time, this could be arbitrarily added without breaking anything before accepting this merge.

  • KeyPair include a delete(self) function that calls driver.delete_key_pair(self)
  • create_key_pair() comment setup a rtype of KeyPair to make explicit that create_key_pair() returns a KeyPair instance ( like create_node returns a Node )

Javier Castillo II and others added 6 commits April 11, 2015 01:26
Pulled connection/response from libcloud.compute.driver.digitalocean into libcloud.common.digitalocean
Implemented majority functions in libcloud.dns.driver.digitalocean
- Added 'common' to FIXTURES_ROOT for FileFixtures in test/common
- Modified DigitalOceanBaseDriver from compute/drivers/digitalocean into common/digitalocean to support v1 and v2 by initialization
- Added dns/driver/digitalocean tests
- Added common/digitalocean tests
… tests from dns/test_digitalocean performed in DigitalOceanBaseDriver
- Support for v1 and v2 initialization with authentication secret
- Updated v1 DigitalOceanNodeDriver to use updated KeyPair Management
- Updated tests to reflect KeyPair Management changes
@jcastillo2nd
Copy link
Contributor Author

I'm wondering if the hack is what is causing the provider feature matrix build to fail.

https://github.com/jcastillo2nd/libcloud/blob/trunk/contrib/generate_provider_feature_matrix_table.py#L224

Should this also include a check if this is node driver vs dns driver to let the normal driver selector hit without overriding?

        elif name.lower() == 'digital_ocean' and api != 'dns':

@Kami
Copy link
Member

Kami commented Apr 15, 2015

Great, thanks!

I will have a look asap.

@jcastillo2nd
Copy link
Contributor Author

I'm thinking the hack can be removed entirely since the DigitalOceanNodeDriver can handle both cases with just passing of the secret or key only:

>>> from libcloud.compute.drivers.digitalocean import DigitalOceanNodeDriver
>>> n1 = DigitalOceanNodeDriver('v1_key', 'v1_secret')
>>> n1.__class__
<class 'libcloud.compute.drivers.digitalocean.DigitalOcean_v1_NodeDriver'>
>>> n2 = DigitalOceanNodeDriver('v2_key')
>>> n2.__class__
<class 'libcloud.compute.drivers.digitalocean.DigitalOcean_v2_NodeDriver'>

Also, I'm pulling the ex_ssh functions back into the v1 driver to live alongside the key pair functions so it doesn't break existing functionality. Poor foresight on my part.

- Removed hack to load DigitalOcean_v2_NodeDriver as DigitalOceanNodeDriver will handle v1/v2 properly
- Restored DigitalOceanNodeDriver (v1) ex_ssh* methods with Warning of deprecation
@jcastillo2nd
Copy link
Contributor Author

Looks like removing the hack worked as it handles the tests properly for both v1 and v2 cases in DigitalOceanNodeDriver, also the old ex_ssh_* functions have been restored to v1, but with warnings.warn regarding deprecation.

This looks good from a working build perspective, let me know if there is anything else needed on this.

- Includes driver instantiation example
- Updated Node driver documentation to reflect duality of v1/v2 api in DigitalOceanNodeDriver
- Updated documentation for DigitalOcean regarding locations
- Fixed type for DigitalOcean DNS documentation
@@ -2,4 +2,4 @@
from libcloud.compute.providers import get_driver

cls = get_driver(Provider.DIGITAL_OCEAN)
driver = cls('client id', 'api key', api_version='v1')
Copy link
Member

Choose a reason for hiding this comment

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

This is a minor thing - I prefer to be explicit and explicitly specify an api version. This way it's immediately obvious which API version is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, sorry for the delay. Personal life had some crazy changes cutting my time for projects to almost nothing. Going over these, and they should be easy to get done over the next couple days.

As for this entry in particular, I agree it should be explicit here as well. I'm also going to update the v2 API compute example to include the api_version='v2' as well.

@Kami
Copy link
Member

Kami commented May 3, 2015

I've added some comments.

Overall the PR looks good, but there are some small things which need to be addressed so we can get it merged.

@Kami
Copy link
Member

Kami commented May 16, 2015

@jcastillo2nd Sorry for the delay and please ping me when those comments are addressed - I would love to get this change included in the next release.

- Raise on api_version / key or key-secret mismatch
- Added tests for v1 and v2 DigitalOceanNodeDriver using wrong keys
- Updated examples to include explicit api_version values
- Raise on api_version / key or key-secret mismatch
- Added tests for v1 and v2 DigitalOceanNodeDriver using wrong keys
- Updated examples to include explicit api_version values
- Cleaned up some whitespace lint
- Raise on api_version / key or key-secret mismatch
- Added tests for v1 and v2 DigitalOceanNodeDriver using wrong keys
- Updated examples to include explicit api_version values
- Cleaned up some whitespace lint
- Cleaned up tests
@jcastillo2nd
Copy link
Contributor Author

@Kami Hopefully I've clarified the issues with the current code and moved things in the right direction. Let me know what your thoughts are on the pending issues.

- v2 driver referenced object instead of response
- v2 driver referenced object instead of response
- Update v2 Node driver to properly set data instead of parameters for API requests
- Added ex_ssh_key_ids to create_node
- Implemented list_key_pairs with public key retreival
- Consistency in v2 for attributes -> json request data
@jcastillo2nd jcastillo2nd mentioned this pull request May 28, 2015
@jcastillo2nd
Copy link
Contributor Author

@Kami I've got some time over the next couple of weeks to work on anything else that may come up on this. If there are still any issues keeping this from being merged, I will hopefully be able to resolve them before the next release is established.

@asfgit asfgit closed this in fa6c99d Jun 14, 2015
@Kami
Copy link
Member

Kami commented Jun 14, 2015

I restored a slightly modified hack to make the table generation script work again (8952234) and merged changes into trunk.

Thanks.

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