kapilt / juju-digitalocean

JuDo - A juju provider for digital ocean using a client side plugin and manual provisioning.
111 stars 17 forks source link

Added support for digitalocean api v2 #32

Closed dangyogi closed 9 years ago

dangyogi commented 9 years ago

This adds support for digitalocean's v2 api, while not breaking current users still using the v1 api. This should fix the issue https://github.com/kapilt/juju-digitalocean/issues/25.

I've updated the README.rst file, but not the tests. I also don't have access to the v1 api to test that I didn't break that. Since I made rather substantial changes, that's a definite possibility.

The code now looks for the DO_CLIENT_ID/DO_API_KEY env vars, or a new DO_OAUTH_TOKEN env var. Which of these are set determines whether it uses the v1 or v2 api.

I'm still a bit new to both github and git (am more of a mercurial user), so it might be helpful to spell things out a bit more if you need changes made, or whatever.

I've successfully done the "bootstrap", "add-machine", "list-machines", "terminate-machine" and "destroy-environment" commands with v2 running on digitalocean. Again, somebody else will have to try it on v1.

kapilt commented 9 years ago

wow totally didn't see this, thanks, reviewing now.

kapilt commented 9 years ago

so probably don't need to support v1 api anymore, its basically getting turned off in november.

kapilt commented 9 years ago

so one thing that the v2 api opens up for the provider, is the ability to use userdata to provision any non bootstrap server without waiting for ssh, basically we just launch the instance and have userdata initialize the system and connect back to the state server. This will basically turn O(n) provisioning requests into O(1) and greatly speed up using the plugin.

kapilt commented 9 years ago

also need some fixes to run the unit tests.

dangyogi commented 9 years ago

Kept the v1 support so current users could upgrade without getting shut down. Don't know if that was the right decision.

Your second email about using userdata with the v2 api to turn provisioning requests from O(n) to O(1) is over my head. I'm still new to digitalocean and juju. Don't know what userdata is, or what the state server is. So I don't think that I'll be able to help with that one.

I didn't try to run the unit tests. I haven't gotten to the juju test frameworks yet. Just started on charmhelpers yesterday.

I have hit a few more bugs though in my use of this with the v2 api. Should I commit these to the same branch in my fork? Will the current pull request then pick these up, or would I have to submit a new pull request?

-Bruce

On Sun, Jun 21, 2015 at 5:15 PM, Kapil Thangavelu notifications@github.com wrote:

also need some fixes to run the unit tests.

— Reply to this email directly or view it on GitHub https://github.com/kapilt/juju-digitalocean/pull/32#issuecomment-113960661 .

dangyogi commented 9 years ago

OK, I committed my fixes, and it looks like github automatically added these to the pull request.

On Sun, Jun 21, 2015 at 9:41 PM, Bruce Frederiksen dangyogi@gmail.com wrote:

Kept the v1 support so current users could upgrade without getting shut down. Don't know if that was the right decision.

Your second email about using userdata with the v2 api to turn provisioning requests from O(n) to O(1) is over my head. I'm still new to digitalocean and juju. Don't know what userdata is, or what the state server is. So I don't think that I'll be able to help with that one.

I didn't try to run the unit tests. I haven't gotten to the juju test frameworks yet. Just started on charmhelpers yesterday.

I have hit a few more bugs though in my use of this with the v2 api. Should I commit these to the same branch in my fork? Will the current pull request then pick these up, or would I have to submit a new pull request?

-Bruce

On Sun, Jun 21, 2015 at 5:15 PM, Kapil Thangavelu < notifications@github.com> wrote:

also need some fixes to run the unit tests.

— Reply to this email directly or view it on GitHub https://github.com/kapilt/juju-digitalocean/pull/32#issuecomment-113960661 .

kapilt commented 9 years ago

Thanks! I'm traveling atm, but will make some time to look over the next few days.

kapilt commented 9 years ago

looks good, i've fixed the tests and other minors. changed default client behavior to use v2 first. unit tests won't pass with v1, but given rapidly approaching sunset of that i'm not concerned.

kapilt commented 9 years ago

re the userdata speedup, i'll save for another branch, it requires pulling in python-jujuclient as a dep, but that seems fine given the significantly better user experience (ie. faster provisioning).