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

Add agent for OVH Cloud (REST API) #202

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

cymen
Copy link

@cymen cymen commented May 6, 2018

This adds an agent for the OVH Cloud servers via the REST API. The REST API uses Oauth for authentication. Because of the authentication method, the agent ends up expecting an application key, an application secret and a consumer key or token. Getting/creating these values is explained at First Steps with the API. When creating the consumer key or token, it's important to select the option that disables expiration of it. Noting this here as it was unclear where this kind of documentation should go.

I'm also a bit unclear on the metadata aspect however I've implemented both on and off (with polling to verify status before it exits with return value 0 or 1).

@knet-ci-bot
Copy link

Can one of the admins verify this patch?

@cymen
Copy link
Author

cymen commented May 6, 2018

It's failing CI now on absence of tests/data/metadata/fence_ovh_cloud_rest.xml. Is that a hand created file or should the metadata part (that I mentioned being confused about above) be implemented and then this is generated?

Updated: figured that out -- that last bit of the doc at FenceAgentAPI hinted at what to do.


rescue_url = "/cloud/project/%s/instance/%s/rescueMode" % (options['--service-name'], options['--instance-id'])

if options["--action"] == "off":
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should put the on/off code into e.g. set_power_status() and make a get_power_status() where it returns on/off/unknown. This way it can e.g. send reboot as send power-off, wait for power off, send power-on, wait for power-on.

Similar agent with a good example on how to do this:
https://github.com/ClusterLabs/fence-agents/blob/master/agents/vmware_rest/fence_vmware_rest.py#L178

Copy link
Author

Choose a reason for hiding this comment

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

Ah, good idea. I misread part of the FenceAgentAPI doc and thought it meant reboot was a bad idea in general (but I see it suggests that only that is a bad idea for fabric fencing).

I'll make this change.

Copy link
Author

Choose a reason for hiding this comment

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

@oalbrigt One question -- does it matter if my get_power_status fails? As in, will the code in fencing.py retry until it gets a valid status? Or does my code need to sleep and poll until it gets a valid power status (as I've done in the code here)? It's not 100% obvious to me as I don't know if the vmware example one sometimes returns states between off and on as the OVH one does (ie if going to RESCUE, it returns RESCUING until it is ready and then RESCUE).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just make it return Unknown when it's in those states. That way it will keep on trying until it gets OFF/ON or times out. You can try running it with -o off, on or reboot and using the -v parameter to see what it's actually doing (requires you to use "result = fence_action(conn, options, set_power_status, get_power_status, get_list)" to set the functions used for set_power_status/get_power_status).

@oalbrigt
Copy link
Collaborator

oalbrigt commented May 7, 2018

You can run "make xml-upload" to generate/update this.

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.

3 participants