Added OVH Ip loadbalancing module for managing backends #1324
Conversation
''' | ||
|
||
import sys | ||
import ovh |
There was a problem hiding this comment.
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.
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 ? |
@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
I've made some improvements based on @mscherer review. Pascal ready_for_review |
ready_for_review |
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 |
There was a problem hiding this comment.
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 ?
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) |
completion of a task.
Added a timeout param to prevent infinite loop |
Added missing exceptions handling
Added exceptions handling |
I checked the module with pep8 and it has now 0 warning in pep8. |
ready_for_review |
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. |
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) |
There was a problem hiding this comment.
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.
@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! |
ready_for_review |
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.] |
shipit |
@mscherer can you take a look? |
It would be awesome to see this merged. Looks like the code is OK, what are we waiting for? |
@Flaburgan test it, type 'shipit' in a comment if it is ok, and the plugin will be marked for inclusion. |
@mscherer already gave another one and he is deeply involved in ansible ;) |
@Flaburgan He gave one at the previous review stage, not this final one, no ? |
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. |
Testing this module will be quite hard if you dont have a iploadbalancing and two servers with correct setup. |
👍 |
- 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 |
There was a problem hiding this comment.
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
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. |
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. |
Merged. Starts here: a767da1 |
Thanks @pascalheraud for writing this, @mscherer and @hedii for reviewing and testing. Sorry it took so long. |
Thank you very much ! :) |
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.