Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Added OVH Ip loadbalancing module for managing backends #1324

Closed
wants to merge 13 commits into from

Conversation

pascalheraud
Copy link
Contributor

Hello,

Here is a module I've written for managing OVH IP Loadbalancer.
The OVH api is a very comprehensive API and could need several Ansible modules.
I think it's a good start for supporting this API through Ansible.

Pascal.

'''

import sys
import ovh
Copy link
Contributor

Choose a reason for hiding this comment

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

you should wrap that import in a try/catch ( like https://github.com/ansible/ansible-modules-extras/blob/devel/system/firewalld.py#L94 ) and show a error message if the ovh module is not present.

@mscherer
Copy link
Contributor

mscherer commented Dec 4, 2015

There is also not much error handling in the module, so if something fail, we would have a backtrace rather than a clean error, could it be added ?

@gregdek
Copy link
Contributor

gregdek commented Dec 4, 2015

@pascalheraud After some review, it looks as though this PR needs some revisions.

Please make the suggested revisions, and when you're done, please add a comment with the text "ready_for_review" and we will continue with the review process. Thanks!

- Caught the exception from import ovh to provide a proper message to
the user
- Removed unuseful brackets
- Added a else to check the state instead of two if
- Changed the module to be added to 2.0
- Added exceptions handling for all APIs calls with a clear message
including the return from the API.

And : 
- Fixed dependency of OVH api to 0.3.5
@pascalheraud
Copy link
Contributor Author

I've made some improvements based on @mscherer review.
Thank you for your input.

Pascal

ready_for_review

@pascalheraud
Copy link
Contributor Author

ready_for_review

@gregdek
Copy link
Contributor

gregdek commented Dec 6, 2015

Thanks @pascalheraud for this new module. When this module receives 'shipit' comments from two community members and any 'needs_revision' comments have been resolved, we will mark for inclusion.


def waitForNoTask(client, name):
while len(client.get('/ip/loadBalancing/{}/task'.format(name)))>0:
time.sleep(1) # Delay for 1 sec
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no timeout, nor any kind of mutex, so this could loop forever in theory, no ? Shouldn't something be done for that ?

@mscherer
Copy link
Contributor

mscherer commented Dec 6, 2015

Also, as a general note, I think it would be nicer to make sure that the code is clean when it come to the pep8 (at least, for new code, since the discussion I see on the list are mostly about fixing the existing code base, but new one have no reason to not be clean). But I am not sure on what is the consensus of the community around it.

Can you verify with make pep8 that at least, the module is clean ? (the rest of the code base is not, so you will see a ton of errors)

@pascalheraud
Copy link
Contributor Author

Added a timeout param to prevent infinite loop

Added missing exceptions handling
@pascalheraud
Copy link
Contributor Author

Added exceptions handling
Removed unnecessary moduleChanged=False

@pascalheraud
Copy link
Contributor Author

I checked the module with pep8 and it has now 0 warning in pep8.

@pascalheraud
Copy link
Contributor Author

ready_for_review

@gregdek
Copy link
Contributor

gregdek commented Dec 8, 2015

Thanks @pascalheraud for this new module. When this module receives 'shipit' comments from two community members and any 'needs_revision' comments have been resolved, we will mark for inclusion.

@abadger
Copy link
Contributor

abadger commented Apr 20, 2016

I think the code here looks good now. However, there's a lot of string formatting issues. Some of them might break the docs building and some of them will lead to oddly formatted messages. I'll add some contextual notes to the first occurrence of the problems and you can fix the rest. Once you fix those I think we can merge this.

notes:
- Uses the python OVH Api U(https://github.com/ovh/python-ovh). \
You have to create an application (a key and secret) with a consummer \
key as described into U(https://eu.api.ovh.com/g934.first_step_with_api)
Copy link
Contributor

Choose a reason for hiding this comment

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

Python multiline strings (started and stopped using triple quotes like `'''and"""``` do not need the backslash as a line continuation character. So you can remove all trailing backslashes at the end of lines within triple quoted strings.

I can't be certain but you may have added them in here because you weren't sure how yaml was parsing the documentation. If so, the problem is not that the line needs to be continued. Instead, it's that the indentation level is wrong. In order for YAML to understand that all of this is one entry, you probably need to make sure the indent lines up with the other text, not with the character introducing the element. IE: The "Y" in You needs to be directly underneath the "U" in Uses. Similarly, the "k" in key needs to be directly underneath those.

@gregdek
Copy link
Contributor

gregdek commented May 4, 2016

@pascalheraud please respond to @abadger's concerns, and when you've done so, please respond with "ready_for_review" and we'll get it back on track. Thanks!

@pascalheraud
Copy link
Contributor Author

ready_for_review

@gregdek
Copy link
Contributor

gregdek commented May 8, 2016

Thanks @pascalheraud for this new module. When this module receives 'shipit' comments from two community members and any 'needs_revision' comments have been resolved, we will mark for inclusion.

[This message brought to you by your friendly Ansibull-bot.]

@hedii
Copy link

hedii commented May 9, 2016

shipit

@hedii
Copy link

hedii commented May 11, 2016

@mscherer can you take a look?

@Flaburgan
Copy link

It would be awesome to see this merged. Looks like the code is OK, what are we waiting for?

@hedii
Copy link

hedii commented May 19, 2016

@Flaburgan test it, type 'shipit' in a comment if it is ok, and the plugin will be marked for inclusion.
(the plugin needs 2 'shipit' comments, i already gave one. Only another one is missing)

@Flaburgan
Copy link

@mscherer already gave another one and he is deeply involved in ansible ;)

@hedii
Copy link

hedii commented May 19, 2016

@Flaburgan He gave one at the previous review stage, not this final one, no ?

@mscherer
Copy link
Contributor

Yeah, I think the code is ok (still need to review one last time), but testing it would requires a bit more time from me, cause i would need a account on ovh cloud, and then setup 2 cloud servers and everything, that need a bit more time on my side and doc reading than just reading python.

@pascalheraud
Copy link
Contributor Author

Testing this module will be quite hard if you dont have a iploadbalancing and two servers with correct setup.
To setup a env like that will be time and money !

@theyough
Copy link

👍

- ovh_ip_loadbalancing name=ip-1.1.1.1 backend=212.1.1.1
state=present probe=none weight=8
endpoint=ovh-eu application_key=yourkey
application_secret=yoursecret consumer_key=yourconsumerkey
Copy link
Contributor

@abadger abadger Jul 26, 2016

Choose a reason for hiding this comment

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

The examples will still format funny. They should look liek this:

- ovh_ip_loadbalancing:
    name: ip-1.1.1.1
    backend: 212.1.1.1
    state: present
    probe: none
    weight: 8
    endpoint: ovh-eu
    application_key: your_key
    application_secret: yoursecret
    consumer_key: yourconsumerkey

@abadger
Copy link
Contributor

abadger commented Jul 26, 2016

per our previous discussion of this code, this is looking good. I found a few things to change but I can do those when I merge.

@abadger
Copy link
Contributor

abadger commented Jul 26, 2016

I'm heading out to ansiblefest in San Francisco right now. So I'll get to it once I arrive unless you get to it first.

@abadger
Copy link
Contributor

abadger commented Jul 27, 2016

Merged. Starts here: a767da1

@abadger
Copy link
Contributor

abadger commented Jul 27, 2016

Thanks @pascalheraud for writing this, @mscherer and @hedii for reviewing and testing. Sorry it took so long.

@abadger abadger closed this Jul 27, 2016
@pascalheraud
Copy link
Contributor Author

Thank you very much ! :)

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

Successfully merging this pull request may close these issues.

None yet

8 participants